Public Function random_key(ByVal lenght As Integer) As String
Randomize()
Dim s As New System.Text.StringBuilder("")
Dim b() As Char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".ToCharArray()
For i As Integer = 1 To lenght
Randomize()
Dim z As Integer = Int(((b.Length - 2) - 0 + 1) * Rnd()) + 1
s.Append(b(z))
Next
Return s.ToString
Console.WriteLine(s.ToString)
End Function
我想把它打印出来
s = textbox1.text或somethhing ...
答案 0 :(得分:1)
使用Console.WriteLine
有什么问题?
请注意,您不应该将其放在方法中的return
statement后面,因为返回后面的代码是unreachable。
Dim random As String = random_key(10)
Console.WriteLine(random)