Hi, i would like to know how to create a random code.
here's how it goes:
I have this page where i can add a user in access database.
when i have added this user, i want a random password to be entered in this MEM_PASSWORD. Is there a possibility to generate a random code.
It should look a bit like this: EFOF98QBZ
just numbers and capital letters.
thanks in advanceWell the ASCII Codes
"A" =65
"Z" =90.
"0" = 48
"9" = 57
Dim intLength
Dim intMaxLength
intLength = 0
intMaxLength = 10
Dim strChar
Do while intLength < intMaxLength
strChar = strChar & Chr(Int((90 - 65+ 1) * Rnd + 65))
intLength = intLength + 1
loop
so you can do some math...Hey,
Thank you, it's very kind to help me out. But could you please write some comment in the code you wrote.
I try to understand the code you made, and i'm not the kind of person who just copy/pastes it.
It would be very kind...
thanks in advance.Dim intLength
Dim intMaxLength
intLength = 0
intMaxLength = 10
Dim strChar
'Loop until our lenght of the string is the password length we need.
Do while intLength < intMaxLength
'90 We know is "Z" and 65 is "A". So generate a random number (Random numbers are between 0 and 1 with a floating point value). Multiple the value by the smallest value and Random value.
strChar = strChar & Chr(Int((90 - 65+ 1) * Rnd + 65))
'Incerment our length variable so that we can exit the loop.
intLength = intLength + 1
loopthank you so much for your explanation!
wish all forums were this helpfull.
here's how it goes:
I have this page where i can add a user in access database.
when i have added this user, i want a random password to be entered in this MEM_PASSWORD. Is there a possibility to generate a random code.
It should look a bit like this: EFOF98QBZ
just numbers and capital letters.
thanks in advanceWell the ASCII Codes
"A" =65
"Z" =90.
"0" = 48
"9" = 57
Dim intLength
Dim intMaxLength
intLength = 0
intMaxLength = 10
Dim strChar
Do while intLength < intMaxLength
strChar = strChar & Chr(Int((90 - 65+ 1) * Rnd + 65))
intLength = intLength + 1
loop
so you can do some math...Hey,
Thank you, it's very kind to help me out. But could you please write some comment in the code you wrote.
I try to understand the code you made, and i'm not the kind of person who just copy/pastes it.
It would be very kind...
thanks in advance.Dim intLength
Dim intMaxLength
intLength = 0
intMaxLength = 10
Dim strChar
'Loop until our lenght of the string is the password length we need.
Do while intLength < intMaxLength
'90 We know is "Z" and 65 is "A". So generate a random number (Random numbers are between 0 and 1 with a floating point value). Multiple the value by the smallest value and Random value.
strChar = strChar & Chr(Int((90 - 65+ 1) * Rnd + 65))
'Incerment our length variable so that we can exit the loop.
intLength = intLength + 1
loopthank you so much for your explanation!
wish all forums were this helpfull.