borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to Auto start a program at startup and tool tip ballon shape)Next Topic (How to add icon at the startup bar - bottom right corner) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Cdate function
Poster Message
moja
Level: Guest


icon Cdate function  Archived to Disk

I tried to use Cdate to subtract two "times", but it didn't work

ex. 2:10 - 1:10 = 1:00

what function can i use.

11-05-2002 at 08:34 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Cdate function  Archived to Disk

Here's another way to do times... I was thinking there was an easier way, but can't remember offhand.

Generally you can use CDate(), Format(), DateAdd(), the following code, or a combination of functions.


Private Sub Form_Load()
    Dim hr1 As Integer
    Dim mn1 As Integer
    Dim sc1 As Integer
    Dim hr2 As Integer
    Dim mn2 As Integer
    Dim sc2 As Integer

    hr1 = Format("2:10", "h")
    mn1 = Format("2:10", "n")
    sc1 = Format("2:10", "s")
    
    hr2 = Format("2:15", "h")
    mn2 = Format("2:15", "n")
    sc2 = Format("2:15", "s")
    
    MsgBox ("Hrs: " & hr2 - hr1 & " Minutes: " & mn2 - mn1 & " Seconds: " & sc2 - sc1)
End Sub

11-05-2002 at 09:32 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Cdate function  Archived to Disk

As soon as I posted, I found it...


DateDiff("n","2:10","2:15")

Lookup DateDiff in the msdn library for all the options, "n" is minutes, "s" is seconds, "h" is hours.

11-05-2002 at 09:36 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : Cdate function
Previous Topic (How to Auto start a program at startup and tool tip ballon shape)Next Topic (How to add icon at the startup bar - bottom right corner) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder