Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with RND() and Timer combined. Please Help

Status
Not open for further replies.

chrislr5

MIS
Nov 20, 2002
5
US
Please help me!! I need to generate three random numbers and display them in a label. The thing is i need to make the numbers keep changing for three seconds within the label and then stop. You must see them changing. I can only get the numbers to generate once when putting the following code under the button click event. When i put it under the timers tick event it changes but only after every three seconds. Please tell me how i can change the numbers again and again within the label for three seconds and then stop.

Dim num1, num2, num3 As Integer
num1 = Int(9 * Rnd() + 0)
num2 = Int(9 * Rnd() + 0)
num3 = Int(9 * Rnd() + 0)
Me.label1.Text = num1
Me.label2.Text = num2
Me.label3.Text = num3
 
Set your timer interval to a tenth of a second (100 ms) to update your numbers, then count 30 timer-worths, turning off the timer after that.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top