Solved

Subtract time from time

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now