Generate Random String Using ASP Classic VB script, Sql
Simple and highly customizable function so that you can generate random strings using VBScript that you can use in your ASP/VBScript applications. The random strings can be used for various purposes: Referral Codes, Promotional Codes, Random password for new registrations
function GetRefID(Val)tot_unique=8
rid = ""
redim random_letter(tot_unique)
randomize
For counter = 1 to tot_unique
random_number = Int(26 * Rnd + 97)
random_letter(counter) = Chr(random_number)
'response.write random_letter(counter)
for check=1 to counter-1
if random_letter(check)= random_letter(counter) then
counter=counter-1
end if
next
next
For counter = 1 to tot_unique
'response.write "
rid=rid & random_letter(counter)
next
Userid= Val & rid
Sql="Select id from tbl Where id ='"&Userid&"' "
Set Rs = objcon.execute(Sql)
IF Not Rs.eof then
GetRefID()
Else
GetRefID= Userid
End IF
Rs.close()
Set Rs = Nothing
End Function
No comments:
Post a Comment