我想要一种超级简单的方法,用一个随机字符替换字符串中的另一个字符。到目前为止,对于如此简单的事情,我发现非常复杂。
Dim result As String
For Each character As String In FormatTextBox.Text
If character = "c" Then
result += GetRandomLetter(97, 123)
ElseIf character = "C" Then
result += GetRandomLetter(65, 91)
Else
result += character
End If
Next
Public Function GetRandomLetter(AsciStart As Integer, AsciEnd As Integer) As Char
Dim TheIndex As Integer = RandomNumber.Next(AsciStart, AsciEnd)
Return Chr(TheIndex)
End Function