Random

  • Thread starter Thread starter Geoldr
  • Start date Start date
take a.look at Random....ex

Private Sub Button1_Click(...)

Dim rnd As New Random

Me.Label1.Text = rnd.Next(1, 11)

End Sub


i believe the .Next method's parameters are

first number = base, bottom number (inclusive)
second number = highest number (non inclusive)

this will give you a "random" number between 1 and 11


hope this helps
 
iwdu15 said:
take a.look at Random....ex

Private Sub Button1_Click(...)

Dim rnd As New Random

Me.Label1.Text = rnd.Next(1, 11)

End Sub


i believe the .Next method's parameters are

first number = base, bottom number (inclusive)
second number = highest number (non inclusive)

this will give you a "random" number between 1 and 11


hope this helps

Yep, it worked.
Thanks for the help!
 
iwdu15 said:
Private Sub Button1_Click(...)

Dim rnd As New Random

Me.Label1.Text = rnd.Next(1, 11)

Note that you should create only a single instance of 'Random' in this case:

\\\
Private m_Random As New Random()
....
Me.Label1.Text = CStr(m_Random.Next(...))
///
 
Back
Top