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.
'***** make random password ******
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
'----------
Function GeneratePassword(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
GeneratePassword = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePassword <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePassword = GeneratePassword & c
Next
If Len(GeneratePassword nLength) Then
GeneratePassword = Left(GeneratePassword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePassword(6)
'**************************************
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 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
news:46***********************@roadrunner.com...
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.
'***** make random password ******
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
'----------
Function GeneratePassword(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
GeneratePassword = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePassword <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePassword = GeneratePassword & c
Next
If Len(GeneratePassword nLength) Then
GeneratePassword = Left(GeneratePassword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePassword(6)
'**************************************
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andreas Lobinger |
last post by:
Aloha,
i wanted to ask another problem, but as i started to build an example...
How to generate (memory and time)-efficient a string containing...
|
by: Rob Meade |
last post by:
Hi all,
I need to be able to create some license keys for an application. Ideally
these wouldn't be too long in length (ie, easier to...
|
by: Luke |
last post by:
Hello,
I am the administrator for http://www.nickberg.org - Nick is the man
who was recently beheaded in Iraq.
He was a very ingenious man -...
|
by: anita |
last post by:
I had posted this question before, but did not hear from anybody.
Can somebody pls help me out.
I am creating a table with two fields F1, F2 and F2...
|
by: aahmad76 |
last post by:
Can anyone please help me. I am trying to desing a
program that will create a 10 digit alphanumeric
password. I am new to the Vb.net environment,...
|
by: fieldfallow |
last post by:
Hello all,
Is there a function in the standard C library which returns a prime
number which is also pseudo-random?
Assuming there isn't, as it...
|
by: Tuvas |
last post by:
Okay, I'm working on devoloping a simple, cryptographically secure
number, from a range of numbers (As one might do for finding large
numbers, to...
|
by: stjulian |
last post by:
I have used
set typ = server.createobject("Scriptlet.TypeLib")
to create a random string of 36 characters. However, is there a way to
create...
|
by: tshad |
last post by:
I have a page that I am getting a username and password as a random number
(2 letters, one number and 4 more letters)
I have 2 functions I call:...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |