943,691 Members | Top Members by Rank

Ad:
Jun 29th, 2007
0

random letters/numbers

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
brian.p is offline Offline
9 posts
since Jan 2007
Jun 29th, 2007
0

Re: random letters/numbers

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
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007
Jun 30th, 2007
0

Re: random letters/numbers

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

thanks Denis
Reputation Points: 10
Solved Threads: 0
Newbie Poster
brian.p is offline Offline
9 posts
since Jan 2007
Jun 30th, 2007
0

Re: random letters/numbers

No problem - glad it works for you.

Denis
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB Runtime Error 429
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Looking for fast treath of Pictureboxes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC