我來這裏請求如何使我的字符串生成器生成TextBox2中鍵入的字符串數量的幫助。例如,如果我在框中鍵入10,它將在RichTextBox1中生成10個字符串,如果我鍵入1,它將生成1等。這是我的代碼。通過文本框中的數字生成隨機字符串(Visual Basic)
Public Function RandomString(ByVal length As Integer) As String
Dim strb As New System.Text.StringBuilder
Dim chars() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
Dim UpperBound As Integer = UBound(chars)
For x As Integer = 1 To length
strb.Append(chars(Int(Rnd() * UpperBound)))
Next
Return strb.ToString
End Function
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Try
System.Diagnostics.Process.Start("Link Removed...")
Catch
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rndstring As String
rndstring = RandomString(24)
RichTextBox1.Text = rndstring
End Sub