Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends.

I want to calculate time difference in vb6. i had been done it in vb.net. but i don't know how to convert in vb6.Because the datetime type will not be available in vb6.

i have pasted my vb.net code below. how to do the same in vb6?

VB
Public Sub timecal()
    Dim dFrom As DateTime
    Dim dTo As DateTime
    Dim tempstarttime As DateTime
    Dim idletime As String = "00:05:00"
    Dim Needtosub As String = "00:01:00"
    Dim timeDiff As String
    If DateTime.TryParse(start_time, dFrom) AndAlso DateTime.TryParse(end_time, dTo) Then
        Dim TS As TimeSpan = dTo - dFrom
        Dim hour As Integer = TS.Hours
        Dim mins As Integer = TS.Minutes
        Dim secs As Integer = TS.Seconds
        timeDiff = ((hour.ToString("00") + ":") + mins.ToString("00") + ":") + secs.ToString("00")
        sscheck1 = False
        If timeDiff >= idletime Then
            tempstarttime = System.DateTime.Parse(end_time)
            tempstarttime = tempstarttime.AddMinutes(-1)
            start_time = Strings.Format(tempstarttime, "yyyy-MM-dd HH:mm:ss")
            sscheck1 = True
        End If
    End If
End Sub
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-14 2:24am    
Any special reason to struggle with VB6?
—SA
jai_mca 6-Aug-14 2:27am    
yes.i don't know what is the vb6 relevent data type of datetime from vb.net
Sergey Alexandrovich Kryukov 6-Aug-14 2:40am    
Can you read my comment? Any special reason to struggle with VB6?
—SA
jai_mca 6-Aug-14 2:45am    
yeah..nothing special reason. i am a newbie to vb6. so i dnt know the procedure in vb6 which i had done in vb.net

Here some information: VB6 - Date and Time Functions[^].
 
Share this answer
 
Comments
jai_mca 6-Aug-14 2:42am    
In that link there is no time difference calculation.
i have two different time with date.i want to subtract the endtime with starttime.
then i want to compare the resulted time.
CPallini 6-Aug-14 2:50am    
You didn't you read the DateDiff section, did you?
jai_mca 6-Aug-14 2:55am    
i want to calculate timediff between starttime and endtime
CPallini 6-Aug-14 3:13am    
Well, no one is preventing you to do that. Again, did you read the DateDiff documentation? See also:
http://www.vb6.us/tutorials/learn-howto-use-visual-basic-datediff-function
jai_mca 6-Aug-14 3:18am    
Thanks Cpallini.
i will go through again
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900