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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

randomize

Status
Not open for further replies.

trevlar04

Programmer
Jan 1, 2002
3
0
0
US
i would like to have the computer randomize which msgbox will appear. For instance..."Heads wins." and "Tails wins." after you click a command button.
For as much as i found out, i have to use "rnd". However, I am not sure.

help would be appreciated.
 
Yes, you would need to use rnd. The way you use it is:
Code:
dim number as integer
randomize timer
number = rnd(highval) + lowval
so, to get one of two message boxes when you click a command button, you would put the following code into the click event of the button:
Code:
Dim number As Integer
Randomize Timer
number = Rnd(2) + 1
Select Case number
Case 1
    MsgBox "Heads Wins"
Case 2
    MsgBox "Tails Wins"
End Select
 
thanks very much Zejjeu592. i couldn't seem to find the answer to that question anywhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top