Welcome to Dream.In.Code
Become a VB Expert!

Join 137,231 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,857 people online right now. Registration is fast and FREE... Join Now!




Time Correction

 
Reply to this topicStart new topic

Time Correction

brottmayer
16 Mar, 2007 - 03:48 PM
Post #1

D.I.C Head
**

Joined: 21 Jan, 2007
Posts: 67


My Contributions
I am trying to get the sum of the two time to come up right when added. For example, when i input 07 24 36 into their appropriate textboxes and then add it to 00 36 24 and then I would like for the out come to be 08 01 00 instead of 07 60 60.

Here's my code what what i have done so far:

CODE

    Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
        Dim Start As Integer
        Dim Approx As Integer
        If ScratchHrBox.Text = "" And ScratchMinBox.Text = "" And ScratchSecBox.Text = "" Then
            MsgBox("You must put in a scratch time")
        ElseIf ApproxHrBox.Text = "" And ApproxMinBox.Text = "" And ApproxSecBox.Text = "" Then
            MsgBox("You must put in an approximate finished time")
        Else
            Start = ScratchHrBox.Text & ScratchMinBox.Text & ScratchSecBox.Text
            Approx = ApproxHrBox.Text & ApproxMinBox.Text & ApproxSecBox.Text
            ApproxTimeLabel.Text = Format((Start + Approx), "00:00:00")
        End If
    End Sub


Any help would be great. Thanks.
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Time Correction
16 Mar, 2007 - 07:17 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
You'll need to treat the time factors like time, not like integers. You need to take into account that that when a certain value of seconds is reached, the minutes need to increment and the seconds reset - same with minutes and hours. I'd suggest adding the components separately, not all as one, and performing a check on the result of each operation.

Alternately, you can take advantage of some of the date/time functions.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:22PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month