Can someone tell me how to generate a random number that i can put into a variable Also how to declare that number an odd or even. Thank you.
Can someone tell me how to generate a random number that i can put into a variable Also how to declare that number an odd or even. Thank you.
Generate a random number
osullivj355
hanisaad
This should do it for you.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim _rnd As New Random
Dim _int As Integer
Dim _low As Integer = 0 Dim _high As Integer = 100_int = _rnd.Next(_low, _high)
If (_int Mod 2) = 0 ThenMsgBox(
"The number " & _int & " is even") ElseMsgBox(
"The number " & _int & " is odd") End If End SubTim Cahill - MSFT
ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbalr/html/6ff7e40e-cec8-4c77-bff6-8ddd2791c25b.htm
mod is short for modulo. It gives the remainder of a division,
ex. 11/4 = 2, remainder 3
(11 mod 4) = 3