Main Topics
Browse All Topicshow do i create a stopwatch timer with vb?
Dim minutes As Integer
Dim seconds As Integer
minutes = mins.Text
seconds = secs.Text
Do Until minutes = 0
minutes = minutes - 1
mins.Text = minutes
Loop
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This one is slightly better
http://www.experts-exchang
Hi Yurich. Thanks for the quick answer, but I still have some problems..
Your code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim start_time As DateTime = DateTime.Now
mins.Text = CType((DateTime.Now - start_time), TimeSpan).ToString();
End Sub
There is an error for (1) the semi-colon, and (2) the minus (-) sign for the two dates.
What I am trying to do is to use the system time to count 1 second, and on every second I want it to do something.
In my case, I want to decrement a counter.
no-no-no, first of all, move out start_time out of the tick event - it should be intitialized in some other place, where you start your stopwatch for example...
1) - remove ; sorry, my C# experience gets in the way ;)
2) stgange, - defined for two dates in c#... then it won't work for you...
if you want to decrement a counter, just put this one in your tick event:
Dim counter as Integer = 1000;
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
counter -= 1 ' decrement by one, you can change it of course
End Sub
and if you need it each second, change you interval for your timer to 1000 (1000 mils = 1 sec)
regs,
yurich
Business Accounts
Answer for Membership
by: YurichPosted on 2005-11-15 at 12:48:34ID: 15298941
drop a timer on your application, add a variable "starttime", set it to DateTime.Now, you can leave the interval to 100 (100 milliseconds), and in the tick event of the timer add the following (label1 will show the time):
' that's in your page load if you want to start it right away on in the button event to start stop watch
Dim start_time as DateTime = DateTime.Now()
...
' that's in the tick event of your timer
Label1.Text = CType( ( DateTime.Now - start_time ), TimeSpan ).ToString();
Regs,
Yurich