Make a form refresh itself
-
I want to make one of my forms refresh itself and all controls in it every few seconds, how would I go about doing this? Thanks in advanced :)
-
I want to make one of my forms refresh itself and all controls in it every few seconds, how would I go about doing this? Thanks in advanced :)
What you need to do is to create a new timer and set the .Interval to the number of few seconds you want multiply by 1000 (ex. 1000 = 1 sec).
Timer1.Interval=3000 'will occur every 3 seconds
After it you need to Enable the timer:Timer1.Enabled=True
In the Timer1_Tick event: ========================= > To update graphic, use Me.Refresh. > To update controls, write the code that does it. Ex:Private Sub Timer1_Tick(...) Me.Refresh ' Refresh the form txtText1.Text = strA ' strA is a string that changed numID.Text = Num3 ' Num3 is an Integer ... End Sub
-
What you need to do is to create a new timer and set the .Interval to the number of few seconds you want multiply by 1000 (ex. 1000 = 1 sec).
Timer1.Interval=3000 'will occur every 3 seconds
After it you need to Enable the timer:Timer1.Enabled=True
In the Timer1_Tick event: ========================= > To update graphic, use Me.Refresh. > To update controls, write the code that does it. Ex:Private Sub Timer1_Tick(...) Me.Refresh ' Refresh the form txtText1.Text = strA ' strA is a string that changed numID.Text = Num3 ' Num3 is an Integer ... End Sub
Ah thanks for the reply, it works perfecly :cool:
-
What you need to do is to create a new timer and set the .Interval to the number of few seconds you want multiply by 1000 (ex. 1000 = 1 sec).
Timer1.Interval=3000 'will occur every 3 seconds
After it you need to Enable the timer:Timer1.Enabled=True
In the Timer1_Tick event: ========================= > To update graphic, use Me.Refresh. > To update controls, write the code that does it. Ex:Private Sub Timer1_Tick(...) Me.Refresh ' Refresh the form txtText1.Text = strA ' strA is a string that changed numID.Text = Num3 ' Num3 is an Integer ... End Sub
The code I just added is VB.NET code. In VB6 the parameters are same, but the event called "Timer" instead of "Tick".
Private Sub Timer1_Timer Me.Refresh ' Refresh the form txtText1.Text = strA ' strA is a string that changed numID.Text = Num3 ' Num3 is an Integer ... End Sub