timer loop

jvcoach23

Well-known member
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
Ive search through the archives but just dont know enough to be able to use any of the code Ive found.

What Im trying to do it create a loop that will run every 30 seconds and fire off a private sub, the private sub is filling 3 datagrids with sql info. Ive tried to work with the timer but have had any success. Can someone show me how you can set the timer to call a private sub every 30 seconds. Is the app locked while that timer is running, Id like to be able to use a mannual refresh button as well.

thanks
shannon
 
Heres an example:
(first drag the timer from the toolbox onto the form)
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True enable the timer
        Timer1.Interval = 30000 set the interval to 30000 milliseconds
which equals 30 seconds
        Timer1.Start() start the timer
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SomeSub() use the Tick event to call the sub, Tick is raised
when the timer reached the interval
End Sub

Private Sub SomeSub()
        MessageBox.Show("Hi") do whatever you want here
End Sub
 
Back
Top