Private Function atoz() As String
' Lower Case
Chr(97 + Rnd() * 862150000 Mod 26)  ' produces a-z
End Function
 
Private Function ZerotoNine() As String
' Numbers
Chr(48 + Rnd() * 862150000 Mod 10) 'produces 0-9
End Function

Hi,
Quick question(this is not homework by the way)the above code does as it says.produces a to z and 0 to 9 but I'd like to combine both so that it will output a to 9

(ie)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,0,1,2,3,4,5,6,7,8,9

My application is generating random letters and numbers which are added to a listbox,however I dont want to concatenate atoz & ZerotoNine,what I'd like to do is combine both as I've stated earlier in one string variable,I tried various different methods to achieve this but I have not been successful..

any help would be appreciated.
thank you for your time.
rgds
brian

How about producing a random number between 1 and 34 ? This is the index to a 34 line array which contains a-z and 0-9.


Denis

yes that would be an easier way of doing it..didn't think of that

thanks Denis

No problem - glad it works for you.

Denis

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.