Excuse me, how do you use the random number generator to choose which of 2 or more numbers to choose?
For example, I want the computer to pick either 2 or 67. No other number. Just those two. Is it possible that any of you can help me? Thanks.
Printable View
Excuse me, how do you use the random number generator to choose which of 2 or more numbers to choose?
For example, I want the computer to pick either 2 or 67. No other number. Just those two. Is it possible that any of you can help me? Thanks.
on a form with a label named Label1 and a button named command1 place this code
VB Code:
Option Explicit Private Sub Command1_Click() Dim intRand As Integer Randomize intRand = Int((2 * Rnd) + 1) Select Case intRand Case Is = 1 Label1.Caption = "2" Case Is = 2 Label1.Caption = "67" End Select End Sub
it works well but of coarse with only 2 numbers to generate it returns a lot of the same hits frequently
just change the code in the select case statement to do what you want to occur if its 2 or 67 :)
I never thought of that! Thanks for your input! :D