Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Explain/Help Randomize

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,50987
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Explain/Help Randomize
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Explain/Help Randomize - 8/21/2007 12:39:33 AM   
  Bob Sanders

 

Posts: 2
Score: 0
Joined: 8/21/2007
Status: offline
I have this script that when executed repeats the same character.  The Last name always comes out something like this:  Atwdt.  The characters in the 2nd and 5th position are always the same.  The script is for testing functionality of a pair of text fields.

'######################################################################################
   Dim LastName, FirstName
   LastName = UCase(RandChar) & RandChar & RandChar & RandChar & RandChar
   FirstName = UCase(RandChar) & RandChar & RandChar & RandChar

   Function RandChar()
       Randomize
       RandChar = Chr(Int(Rnd * 26 + 97))
   End Function
'######################################################################################
 
 
Post #: 1
 
 RE: Explain/Help Randomize - 8/21/2007 2:05:48 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
You only need to "Seed" the Random number generator once. Remove the Randomize statment from the loop and put directly after your declarations.


      

_____________________________

Rischip
Author of - The Grim Linker

(in reply to Bob Sanders)
 
 
Post #: 2
 
 RE: Explain/Help Randomize - 8/21/2007 3:40:43 AM   
  Bob Sanders

 

Posts: 2
Score: 0
Joined: 8/21/2007
Status: offline
The first iteration after modifying the code left me with the same results, but it looks like that was just a coincidence.  It seems to be working as I expected now.  Thanks a bunch!

(in reply to Bob Sanders)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Explain/Help Randomize Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts