Click to See Complete Forum and Search --> : random string VBScript
aska_chage
April 29th, 2001, 08:53 PM
hello,
I want to generate random password for first time use when registration is completed. How to genereate random string/integeer or combination of both in VBScript>?
thanks
chris
shree
April 29th, 2001, 10:34 PM
The following code will produce a strpassword containing 10 alphanumeric characters.
dim rndnum as integer, rndsel as integer, rndchr as integer
dim strpassword as string
strpassword = ""
for i = 1 to 10
rndnum = int(rnd * 10) + 48
rndchr = int(rnd * 26) + 65
rndsel = int(rnd * 2)
strPassword = strpassword & chr$(iif(rndsel = 0, rndnum, rndchr))
next
aska_chage
April 29th, 2001, 10:46 PM
this is for VB, i need it inside my ASP page...i cannot use the iif function in VBScript...
thanks anyway =)
anymore help plz!!
chris
shree
April 29th, 2001, 10:56 PM
then declare a variable chrtouse
if rndsel = 0 then
chrtouse = chr$(rndnum)
else
chrtouse = chr$(rndchr)
endif
strpassword = strpassword & chrtouse
instead of
strpassword = strpassword & chr$(iif(...))
aska_chage
April 30th, 2001, 01:23 AM
well..it does generate random number...but when another user register, it'll generate exactly the same password....and we dun want that to happen...
chris
aska_chage
April 30th, 2001, 01:29 AM
hi, thanks a lot man for your help! =)
i've solved the problem...i just put "Randomize" at the beginning of each loop...that would do...
thanks!!
chris
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.