Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
timer event help in Visual Basic 2010?
Basically I'm creating a count down software where it counts down till a set date. The problem is it doesn't auto refresh the numbers in the texboxes.
how do I make the timer event do that?
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim eventDate As New DateTime(2055, 1, 1) ' lolz
Dim ts As New TimeSpan
ts = eventDate - Date.Now
TextBox1.Text = ts.Days.ToString() ' Days remaining
TextBox2.Text = ts.Hours.ToString() ' Hours remaining
TextBox3.Text = ts.Minutes.ToString() 'Minutes remaining
TextBox4.Text = ts.Seconds.ToString() 'seconds remaining
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
End Sub
End Class
I added the exact code to the timer, but still nothing happens.
Do I need to do any calculations? how?
3 Answers
- GardnerLv 71 decade agoFavorite Answer
Add this to the end of the timer tick event (I assume the event is in the code for the form you are trying to update)
Me.Refresh()
Source(s): VB.NET Programmer - Anonymous1 decade ago
In the timer tick event, calculate the time remaining and update the textboxes.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim eventDate As New DateTime(2055, 1, 1) ' lolz
Dim ts As New TimeSpan
ts = eventDate - Date.Now
TextBox1.Text = ts.Days.ToString() ' Days remaining
TextBox2.Text = ts.Hours.ToString() ' Hours remaining
TextBox3.Text = ts.Minutes.ToString() 'Minutes remaining
TextBox4.Text = ts.Seconds.ToString() 'seconds remaining
End Sub