因此,通過尼索曼這段代碼,隨機字母選擇適合文本框
Dim input As String = TextBox2.Text '<--- this should be input "Hello I am Greg"
TextBox2.Text = "" '<--- clear the textbox to store output
Dim rnd As New Random '<---- generating new random number
For Each c As Char In input '<--- iterate through each character
If rnd.Next() Mod 2 = 0 Then
TextBox2.Text &= UCase(c) '<--- if true then print particular letter in upperCase
Else
TextBox2.Text &= LCase(c) '<--- if true then print particular letter in LowerCase
End If
Next
基本上沒有什麼是應該,將其轉換隨機字母降低,和大寫有50/50的機會。雖然,那個問題是清除文本,並以新的轉換後的格式重寫它,這是問題所在。有沒有辦法讓這項工作,而不必清除文本?爲使我的回答一試
你將不得不要麼清除文字或者只是用新文本替換以前的文本,因爲字符串是不可改變在.NET – 2014-11-04 05:20:07