How to subtract time in '00:00:00' format?

M

Martin Ho

I have a small application which is running every x minutes and I need
to display remaining time on the screen in this format (example):

"Next start will be in: 00:13:25"

, and it should automatically be subtracting second, and minutes, till
it all comes to zero and then my app will start.

I have this code I found somewhere on the internet:
Dim MyDate1 As DateTime = DateTime.Now
Dim MyDate2 As DateTime = MyDate1.AddHours(3000)
Dim difference as TimeSpan
code]

. but I am not getting the rest.
I would of course use some timer and so... but could someone help me
to get time changes displayed in so much needed '00:00:00' format?

thanks a lot

Martin


--------========--------
via www.dotnetboards.com
 
M

Mark Keogh

Snip ---8<---
I have a small application which is running every x minutes and I need
to display remaining time on the screen in this format (example):

"Next start will be in: 00:13:25"
---8<--- Snip


Try String.Format("{0:HH:mm:ss}", Now). Here's a real simple console example

Module Module1
Dim WithEvents oTimer As Timers.Timer

Sub Main()
oTimer = New Timers.Timer(1000)
oTimer.Start()
Console.ReadLine()
oTimer.Stop()
End Sub

Private Sub oTimer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles oTimer.Elapsed
Console.WriteLine(String.Format("{0:HH:mm:ss}", Now))
End Sub
End Module

HTH

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top