I am making an application using VB6 in which a WebBrowser window is launched using this code:
Private Sub Form_Load()
WebBrowser1.Navigate ("http://google.com")
End Sub
How can I make the window refresh the same url every let's say 3 minutes ?
I know it should be something well known but i am still searching my way through VB programming
You don't need 2 timers. just have a global variable globalTimer As Date
that keeps the last time you navigated
You can set Timer1 to run every second or minute. To be more accurate, I recommend every second.
Dim globalTimer As Date
...
Private Sub Timer1_Timer()
If Now >= DateAdd("n", 3, globalTimer) Then ' its been at least 3 minutes since last Navigation
WebBrowser1.Navigate ("http://google.com") ' Navigate
globalTimer = Now ' store the new navigation time
End If
End Sub
You can use a timer to run code at a regular interval.
As the VB6 timer has a maximum interval of ~65s, you can set it to a 60,000ms interval, and keep a separate counter and when it gets to 3, reset it back to 0 and perform a refresh.
Private Sub Timer_Timer
'Increment minute count
FireCount = FireCount + 1
If FireCount = 3 then
'Reset to 0 for next time
FireCount = 0
'Refresh web browser
End If
End Sub