Solved

Subtract time from time

Posted on 1998-11-11
2
167 Views
Last Modified: 2010-04-30
Hi,

I have a total mental block today and need help with this "simplistic" problem...

I have a counter ie "01:00:00". I need to subtract say "00:54:32" from it, giving me the total counter (time) remaining in hh:mm:ss format.

The counter is NOT AM/PM dependant, so using TimeSerial, or TimeValue does not work. Can someone help me out please?

Many thanks.

Kind regards,
   Tony Jones, Queensland, Australia
0
Comment
Question by:netcard
2 Comments
 
LVL 3

Accepted Solution

by:
Sendoh earned 80 total points
ID: 1444438
Hi !

I assume the two source were string cuz you didn't stated cleary what are the type of input and the types of output expected. My proposed answer were :

Private Sub Command1_Click()
    Dim a1 As String
    Dim a2 As String
   
    a1 = "01:00:00"
    a2 = "00:54:32"
    MsgBox Format(CDate(a1) - CDate(a2), "hh:mm:ss")
End Sub
The message pops "00:05:28".
0
 

Author Comment

by:netcard
ID: 1444439
You are an absolute life saver! Thank you very much indeed for a great answer and a damned fast one <g>

All the best.

Kind regards,
    Tony Jones, Queensland, Australia
    Southern Cross Visual Basic Code and Links
    http://www.geocities.com/capecanaveral/6740/

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question