PHP Code:
Public Sub RandByte(ByVal amount As Integer)
Dim randLet As New Random
Dim i As Integer = 0
Dim rndLet As String = ""
Dim strRand As String
Do Until i = amount
strRand = randLet.Next(1, 48)
Select Case strRand.ToString
Case 1
rndLet = rndLet & "a"
Case 2
rndLet = rndLet & "b"
Case 3
rndLet = rndLet & "c"
Case 4
rndLet = rndLet & "d"
Case 5
rndLet = rndLet & "e"
Case 6
rndLet = rndLet & "f"
Case 7
rndLet = rndLet & "1"
Case 8
rndLet = rndLet & "2"
Case 9
rndLet = rndLet & "3"
Case 10
rndLet = rndLet & "4"
Case 11
rndLet = rndLet & "5"
Case 12
rndLet = rndLet & "6"
Case 13
rndLet = rndLet & "7"
Case 14
rndLet = rndLet & "8"
Case 15
rndLet = rndLet & "9"
Case 16
rndLet = rndLet & "!"
Case 17
rndLet = rndLet & "@"
Case 18
rndLet = rndLet & "#"
Case 19
rndLet = rndLet & "$"
Case 20
rndLet = rndLet & "%"
Case 21
rndLet = rndLet & "^"
Case 22
rndLet = rndLet & "&"
Case 23
rndLet = rndLet & "*"
Case 24
rndLet = rndLet & "("
Case 25
rndLet = rndLet & ")"
Case 26
rndLet = rndLet & "g"
Case 27
rndLet = rndLet & "h"
Case 28
rndLet = rndLet & "i"
Case 29
rndLet = rndLet & "j"
Case 30
rndLet = rndLet & "k"
Case 31
rndLet = rndLet & "l"
Case 32
rndLet = rndLet & "m"
Case 33
rndLet = rndLet & "n"
Case 34
rndLet = rndLet & "o"
Case 35
rndLet = rndLet & "p"
Case 36
rndLet = rndLet & "q"
Case 37
rndLet = rndLet & "r"
Case 38
rndLet = rndLet & "s"
Case 39
rndLet = rndLet & "t"
Case 40
rndLet = rndLet & "u"
Case 41
rndLet = rndLet & "v"
Case 42
rndLet = rndLet & "w"
Case 43
rndLet = rndLet & "x"
Case 44
rndLet = rndLet & "y"
Case 45
rndLet = rndLet & "z"
Case 46
rndLet = rndLet & "["
Case 47
rndLet = rndLet & "]"
End Select
i = i + 1
Loop
MsgBox(rndLet)
End Sub
Results 1 to 2 of 2
Thread: Random String Gen
- 13 May. 2010 09:38pm #1
Random String Gen
Shh, I'm watching My little pony.
- 16 May. 2010 06:23pm #2
You could try something equivalent to this:
Code:import random import time def rand_str(i): random.seed(time.time()) str1 = "" for x in range(0,i): str1 += chr(random.randrange(32,251)) return str1 if __name__ == "__main__": for x in range(0,20): print(rand_str(20))