Support Forums

Full Version: [How to] Create random strings(upper,lower and integers)[Src]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(05-12-2011, 11:16 AM)euverve Wrote: [ -> ]A slight change version, with number of random strings to generate.

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:
[Image: 3iTgN.png]
A good mod, you made the source more clear

Nice job, I don't know what someone may need this for, but great job. At least it works.
Pages: 1 2