Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've search through the archives but just don't know enough to be able to use any of the code I've found.

 

What I'm 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. I've 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, I'd like to be able to use a mannual refresh button as well.

 

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

  • *Experts*
Posted

Heres an example:

(first drag the timer from the toolbox onto the form)

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...