How to get time balance in DTPicker
Ex -
2.30 Pm - 4.00 Pm = 2.5
dtpicker1.valuve - dtpicker2.valuve = 2.5
how to write vb6 code for this calculation
Please Help me.......
How to get time balance in DTPicker
Ex -
2.30 Pm - 4.00 Pm = 2.5
dtpicker1.valuve - dtpicker2.valuve = 2.5
how to write vb6 code for this calculation
Please Help me.......
wanted the time difference between two DTPicker controls. The example in the original post ("2.30 Pm - 4.00 Pm = 2.5") is not correct — 2:30 PM to 4:00 PM is 1.5 hours (1 hour 30 minutes). Following the hints from and the DTPicker note from , a simple and robust VB6 approach is to read each control's Value (a Date), subtract, and convert the result (which is in days) into hours or minutes.
A minimal decimal-hours solution:
Dim t1 As Date, t2 As Date
Dim hours As Double
t1 = DTPicker1.Value
t2 = DTPicker2.Value
' Ignore differing dates if only times matter:
t1 = TimeValue(t1)
t2 = TimeValue(t2)
' If end time can be next day:
If t2 < t1 Then t2 = t2 + 1
hours = (t2 - t1) * 24
Label1.Caption = Format$(hours, "0.00") To show hours and minutes (HH:MM):
Dim totalMinutes As Long
Dim h As Long, m As Long
totalMinutes = CLng((t2 - t1) * 24 * 60)
h = totalMinutes \ 60
m = totalMinutes Mod 60
Label1.Caption = CStr(h) & ":" & Right$("0" & CStr(m), 2) Notes and cautions:
TimeValue to ignore dates or set the same date on both values before subtracting. CLng/Format$ for stable rounding and display. Jump to Post— vb5prgrmr 169In the code window, type in DateDiff and press F1 to read all about it and how to use it....
Good Luck
In the code window, type in DateDiff and press F1 to read all about it and how to use it....
Good Luck
In the code window, type in DateDiff and press F1 to read all about it and how to use it....
Good Luck
I have not MSDN collection plese help me...
Then use the online version of MSDN...
http://msdn.microsoft.com/en-us/default.aspx
http://msdn.microsoft.com/en-us/library/b5xbyt6f(VS.80).aspx
Good Luck
dtpicker1
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.