PC Review


Reply
Thread Tools Rate Thread

creating a timer in vb.net

 
 
=?Utf-8?B?YXY=?=
Guest
Posts: n/a
 
      1st Apr 2006
im having a hard time creating a timer in vb.net..
the program should run this way: the timer should only start when you press
a button then stops when presing it again..
my problem is that, how to make an output that will sum up all of the time
spent..
could you please provide me a sample code?
your reply will be greatly appreciated

thanks


 
Reply With Quote
 
 
 
 
Andrej Tozon
Guest
Posts: n/a
 
      1st Apr 2006
In .NET 2.0, there's a Stopwatch class, which would be the simplest tool for
solving your task. For an example on how to use it, please refer to MSDN
documentation:
http://msdn2.microsoft.com/en-us/lib...stopwatch.aspx.

Andrej

"av" <(E-Mail Removed)> wrote in message
news:C988F0B1-328A-454B-AD8A-(E-Mail Removed)...
> im having a hard time creating a timer in vb.net..
> the program should run this way: the timer should only start when you
> press
> a button then stops when presing it again..
> my problem is that, how to make an output that will sum up all of the time
> spent..
> could you please provide me a sample code?
> your reply will be greatly appreciated
>
> thanks
>
>



 
Reply With Quote
 
Heike Kersten
Guest
Posts: n/a
 
      3rd Apr 2006
hello,

do you look for something like that (?):

Public Class Form1
Dim DiffZeit As Date
Dim TSpan As TimeSpan

Private Sub BtnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnStart.Click
Timer1.Enabled = True
DiffZeit = DateTime.Now
End Sub

Private Sub BtnStop_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnStop.Click
Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
TSpan = DateTime.Now.Subtract(DiffZeit)
Label1.Text = TSpan.Days & ":" & TSpan.Hours & ":" & TSpan.Minutes &
":" & TSpan.Seconds
End Sub
End Class


greetings,

heike kersten

"av" <(E-Mail Removed)> schrieb im Newsbeitrag
news:C988F0B1-328A-454B-AD8A-(E-Mail Removed)...
> im having a hard time creating a timer in vb.net..
> the program should run this way: the timer should only start when you
> press
> a button then stops when presing it again..
> my problem is that, how to make an output that will sum up all of the time
> spent..
> could you please provide me a sample code?
> your reply will be greatly appreciated
>
> thanks
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Hi-Res Timer Scott McNair Microsoft VB .NET 10 23rd Feb 2008 05:31 AM
Creating A Timer In A Form =?Utf-8?B?VG9tbXkyMzI2?= Microsoft Access Forms 0 4th Sep 2007 03:52 PM
Creating a web service that uses a timer Brian Bischof Microsoft Dot NET Framework 1 6th Dec 2005 03:25 AM
A VB code for creating count down timer / stopwatch... sanskar_d Microsoft Excel Programming 2 17th Jun 2005 11:46 AM
Creating a timer Jonathan Microsoft Access Database Table Design 0 18th Sep 2003 06:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 PM.