472,328 Members | 1,105 Online

# random numbers and letters

hey gang.

I have a code to create a random string of letters. The number of them can
be whatever I desire.

what i would like to do, is have it both letters and integers. how would i
modify this code to allow that.

Sub StrRandomize(strSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSeed, i, 1))))
Next

Randomize nSeed
End Sub
'----------

Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
For i = 0 To nLength

nRnd = Rnd

(bMadeConsonant <True) AND (nRnd < 0.15) Then

c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
Else

If (bMadeConsonant <True) And (nRnd < 0.95) Then

c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)

Else

c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
End If
End If
Next
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
'**************************************

this gives me 6 letters at random.
for example utjand

i would like it to give say 3 letters and 3 numbers. is this possible with
the code i have?

TIA
Bam
Mar 31 '07 #1
1 2941
scratch that. one of these days I will learn to just think!!

just added 1234567890 in the Const strConsonants = "bcdfghklmnpqrstv"
line, all is well
thanks
"Jeff" <ba*@gig-gamers.comwrote in message
hey gang.

I have a code to create a random string of letters. The number of them can
be whatever I desire.

what i would like to do, is have it both letters and integers. how would i
modify this code to allow that.

Sub StrRandomize(strSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSeed, i, 1))))
Next

Randomize nSeed
End Sub
'----------

Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
For i = 0 To nLength

nRnd = Rnd

(bMadeConsonant <True) AND (nRnd < 0.15) Then

c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
Else

If (bMadeConsonant <True) And (nRnd < 0.95) Then

c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)

Else

c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
End If
End If
Next
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
'**************************************

this gives me 6 letters at random.
for example utjand

i would like it to give say 3 letters and 3 numbers. is this possible with
the code i have?

TIA
Bam

Mar 31 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.