Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomize number 1

Status
Not open for further replies.

scottian

Programmer
Jul 3, 2003
955
GB
How can i create a random number within a loop. so the random number is created for each loop.

"My God! It's full of stars...
 
From th EB help files
Code:
'Randomize statement to generate a seed for the Rnd function.

Randomize                      ' Seed random number generator.
Dice1% = Int(6 * Rnd + 1)      ' Generate first die value.
Dice2% = Int(6 * Rnd + 1)      ' Generate second die value.
Msg$ = "You rolled a " + LTrim$(Str$(Dice1%))
Msg$ = Msg$ + " and a " + LTrim$(Str$(Dice2%))
Msg$ = Msg$ + " for a total of "
Msg$ = Msg$ + LTrim$(Str$(Dice1% + Dice2%)) + "."
MsgBox Msg$                    ' Display message.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top