making a random number appear in a label
What would be the code for a random number, lets say 1-5 to appear in a label?
There is a fine line between genious and insane
Dim iUpper As Integer
Dim iLower As Integer
iUpper = 5
iLower = 1
iRoll = Int((iUpper - iLower + 1) * Rnd + iLower)
labelname.caption = iRoll
That should work. Been awhile since I did that in VB though
~"What''''s this red button do?"
Dim iLower As Integer
iUpper = 5
iLower = 1
iRoll = Int((iUpper - iLower + 1) * Rnd + iLower)
labelname.caption = iRoll
That should work. Been awhile since I did that in VB though
~"What''''s this red button do?"
One more thing I forgot to add. You have to put Randomize before the line where you are using Rnd if you plan on using this more than once. (IE, generating random damage or whatever).
[edited by - Psyberia on June 4, 2003 9:31:22 PM]
[edited by - Psyberia on June 4, 2003 9:31:22 PM]
Or in in the Form_Load() procedure you could just put Randomize Timer. They both work though, up to you
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement