slots help

seanvoth

Well-known member
Joined
Aug 5, 2006
Messages
58
Programming Experience
1-3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim minValue As Integer = 1
Dim maxvalue As Integer = 7
Dim random As New Random
Label1.Text = random.Next(minValue, maxvalue + 1).ToString()
Label2.Text = random.Next(minValue, maxvalue + 1).ToString()
Label3.Text = random.Next(minValue, maxvalue + 1).ToString()
End Sub
 
Sean, you really need to make an effort to explain what you want. One line that doesn't give any relevant details or a code snippet with no explanation just doesn't cut it. If you're not prepared to go to any effort then how can you expect us to? Why should we have to try to figure out what you want if you can't be bothered to tell us? I have no idea what it is that you are asking. Please explain CLEARLY what it is you want, and do so in all threads in future. It isn't that hard.
 
Now how were we supposed to work that out?

You will need to start a Timer and in the Timer's Tick event you will generate the random numbers and update the labels. When you click the Stop button you will stop the Timer and whatever the labels show is the value you use. You should create a single Random object at the class level and use it over and over. Now, for goodness sake don't take this code example absolutely literally. It's an example that you have to adapt to your needs.
VB.NET:
Private myRandom As New Random
Private currentValue As Integer

Private Sub Timer1_Tick(...) Handles Timer1.Tick
    currentValue = Me.myRandom.Next(1, 7 + 1)
    Me.Label1.Text = currentValue.ToString()
    Me.Label.Refresh
End Sub
You add a Timer to your form and set its Interval property to the number of milliseconds you want between refreshes. You call its Start and Stop methods to do the obvious. I've done this for one Label. You have three so you'll need three class level variables to store the numbers and you'll have generate three numbers and update three Labels.
 
Back
Top