random letters/numbers

Thread Solved

Join Date: Jan 2007
Posts: 9
Reputation: brian.p is an unknown quantity at this point 
Solved Threads: 0
brian.p brian.p is offline Offline
Newbie Poster

random letters/numbers

 
0
  #1
Jun 29th, 2007
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Function atoz() As String
  2. ' Lower Case
  3. Chr(97 + Rnd() * 862150000 Mod 26) ' produces a-z
  4. End Function
  5.  
  6. Private Function ZerotoNine() As String
  7. ' Numbers
  8. Chr(48 + Rnd() * 862150000 Mod 10) 'produces 0-9
  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 319
Reputation: DenisOxon is an unknown quantity at this point 
Solved Threads: 15
DenisOxon's Avatar
DenisOxon DenisOxon is offline Offline
Posting Whiz

Re: random letters/numbers

 
0
  #2
Jun 29th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 9
Reputation: brian.p is an unknown quantity at this point 
Solved Threads: 0
brian.p brian.p is offline Offline
Newbie Poster

Re: random letters/numbers

 
0
  #3
Jun 30th, 2007
yes that would be an easier way of doing it..didn't think of that

thanks Denis
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 319
Reputation: DenisOxon is an unknown quantity at this point 
Solved Threads: 15
DenisOxon's Avatar
DenisOxon DenisOxon is offline Offline
Posting Whiz

Re: random letters/numbers

 
0
  #4
Jun 30th, 2007
No problem - glad it works for you.

Denis
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC