05-12-2011, 01:16 PM
(05-12-2011, 11:16 AM)euverve Wrote: A slight change version, with number of random strings to generate.A good mod, you made the source more clear
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If StrLength.TextLength <= 0 Then
MsgBox("Input string length.")
Else
StrOutput.Text = RandomString(StrLength.Text)
End If
End Sub
Function RandomString(ByVal val As Integer) As String
RandomString = ""
Const strUpper As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const strLower As String = "abcdefghijklmnopqrstuvwxyz"
Const strNumbers As String = "1234567890"
Dim strTotal As String = strUpper & strLower & strNumbers
Dim i As Short
For i = 1 To CInt(val)
RandomString = RandomString & Mid(strTotal, Int((Rnd() * Len(strTotal)) + 1), 1)
Next i
End Function
Screenshot: