<%
RandomString = ""
lettersArray = array(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
sChars = Join(lettersArray,"")
iLBound = 1
iUBound = Len(sChars)
Randomize(Timer)
RandomString = ""
For i = 1 to 5
RandomString = RandomString & Mid(sChars, Clng((Clng(iUBound - iLBound) * Rnd) + Clng(iLBound)), 1)
Next
Response.write RandomString
%>
Or with a function:
<%
lettersArray = array(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
Response.write RandomString(lettersArray , 5)
Function RandomString(ByVal aLetters, iLength)
RandomString = ""
sChars = Join(aLetters,"")
iLBound = 1
iUBound = Len(sChars)
Randomize(Timer)
RandomString = ""
For i = 1 to iLength
RandomString = RandomString & Mid(sChars, Clng((Clng(iUBound - iLBound) * Rnd) + Clng(iLBound)), 1)
Next
End Function
%>
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:





by: wrmichaelPosted on 2009-10-21 at 06:56:47ID: 25623982
This is the code to get random numbers.
you will want to change it to allow the random number to be between 0 and size of array
dim mysize
dim randomLetter
mysize = ubound(array)
randomletter = ""
for a = 0 to 4
randomletter = randomletter & lettersArray( int(rnd*mysize)+1 )
next a
make sense?
Select allOpen in new window