473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

timers and timespan

I have a form with 3 textboxes.they are: startTime, stopTime, and
elapsedTimeTxt.
I have a timer object on the form named timer1.timer
I have 2 buttons named start and stop respectively.

I need to use the timespan structure to store the start time stop time and
calculate the elapsed time in hours,minutes and seconds then I need to
display all this in my textboxes.

anybody know a code sample to do this?

(it all has to be done in a system class)
EEEEK !!

Nov 21 '05 #1
1 1480

"WannaBeProgrammer" <Wa***************@discussions.microsoft.com> schrieb im
Newsbeitrag news:B0**********************************@microsof t.com...
I have a form with 3 textboxes.they are: startTime, stopTime, and
elapsedTimeTxt.
I have a timer object on the form named timer1.timer
I have 2 buttons named start and stop respectively.

I need to use the timespan structure to store the start time stop time and
calculate the elapsed time in hours,minutes and seconds then I need to
display all this in my textboxes.

anybody know a code sample to do this?

(it all has to be done in a system class)
EEEEK !!


Hi,

try this:
Dim ts As TimeSpan = DateTime.Now.Subtract(startTime)
Dim zeit As String = ts.ToString
zeit = CStr(ts.Hours).PadLeft(2, "0"c) & ":" & _
CStr(ts.Minutes).PadLeft(2, "0"c) & ":" & _
CStr(ts.Seconds).PadLeft(2, "0"c) & vbCrLf &","&_
CStr(ts.Milliseconds).PadLeft(2, "0"c) & vbCrLf

Greeting

Thomas
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Deiussum | last post by:
I'm running into an issue where I have a timer that appears to be timing out immediately, when it shouldn't be timing out for about int.MaxValue milliseconds. I have written a small app that...
8
by: Paul.Hawkes | last post by:
Hello, I've written a windows service and so far what it does is browse to a shared directory on an extranet. Check to see if any files exist in this folder, if any do, the service downloads,...
3
by: chrisdevey | last post by:
Is there any way to make a System.Timers.Timer adjust for daylight savings time change? In a long running process I set a timer as follows for a daily expiration: _myTimer = new...
2
by: DWalker | last post by:
In Visual Studio (Visual Basic) .NET 2002, I noticed that this: Dim Elapsed as DateTime = Now - Now gives a "compile time" error (error in the IDE), saying that the '-' operator is not...
2
by: ucasesoftware | last post by:
i translate a C# funtion to VB.NET and i have this : Shared Function isAllDay(ByVal ap As Appointment) As Boolean Return ap.DateBegin.TimeOfDay = TimeSpan.Zero AndAlso ap.DateEnd.TimeOfDay =...
1
by: logdenav | last post by:
Hello I'm testing the performance of the System.Timers.Timer class. I created a small program that create 100 User objects. Each USer object create a MyTimer object. The constructor of the User...
13
by: sd00 | last post by:
Hi all, can someone give me some coding help with a problem that *should* be really simple, yet I'm struggling with. I need the difference between 2 times (Target / Actual) However, these times...
6
by: daveL | last post by:
I want to Start a process in a Service once a Week Whats the Best Way to Handle this I have A completed Service with Threading Manager But I dont know the Best way to Start a Process on a...
1
by: abhey | last post by:
i am working on a application which has timers set up in it as System.Threading.Timer timer = new System.Threading.Timer(timerDelegate, autoEvent, new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 0, 0,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.