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!

Help with Timer control please, please, please. 1

Status
Not open for further replies.

chrislr5

MIS
Nov 20, 2002
5
US
Hi please somone help me. I need to generate three random numbers and display them in a label when a button is clicked. However the numbers must keep changing for three seconds and then stop. You must see them change in the label. I use this code to generate the numbers randomly.

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

when i put this code under the button click event it only happens once. When i put it in the timers tick event they only change every three seconds. Please someone tell me how to keep changing the numbers for three seconds and then stop. I've tried everything and am ready to bang my head into the wall.
 
In Form Level Declarations
Private m_Expire as date
in the Timer Event.
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
if Now > m_Expired then
Timer1.enabled = false
end if
in Form_Load
Timer1.Enabled = false
Timer1.Interval = 55
in Button_Click
m_Expire = DateAdd("s", 3, Now)
Timer1.Enabled = true
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks alot for the help! Very good technique, much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top