如何设置它以使文本框中的句子随机(对于每个字母)大写或小写,例如:
"你好,我是Greg"将进入" hEllO i a g gg"
这样的事,谢谢。
答案 0 :(得分:0)
您可以尝试:解释将作为评论
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