Solved

Subtract time from time

Posted on 1998-11-11
2
160 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

778 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