
looks like work done using just left hand
Use this code to calculate time
first of all you need 2 dtpicker
add it using this components--> microsoft windows common control 2 6.0
change datepicker's format to 2-dtptime from property window
if you want to calculate time by current time then you need a timer so add it and change it's interval to 1000
now add 3 labels to display hour,minute and second separately of your calculation
then
change it's name to lblhour,lblmin and lblsec respectively
now this code will work perfactly........
CODE
Dim d1, d2 As Date
Private Sub DTPicker1_Change()
d1 = Format(DTPicker1.Value, "hh:mm:ss")
d2 = Format(DTPicker2.Value, "hh:mm:ss")
lblhour.Caption = DateDiff("h", d1, d2)
lblmin.Caption = DateDiff("n", d1, d2)
lblsec.Caption = DateDiff("s", d1, d2)
End Sub
Private Sub Timer1_Timer()
dtp2.Value = Time 'This will change datepicker's value to current time in every second automatic
End Sub
In this if you don't want to calculate time from current time
do not use timer
use a command button and write this code in it's click event
command button's name = cmdcalculate
CODE
Dim d1, d2 As Date
Private Sub cmdcalculate_Click()
d1 = Format(DTPicker1.Value, "hh:mm:ss")
d2 = Format(DTPicker2.Value, "hh:mm:ss")
lblhour.Caption = DateDiff("h", d1, d2)
lblmin.Caption = DateDiff("n", d1, d2)
lblsec.Caption = DateDiff("s", d1, d2)
End Sub
dream.in.code is a best forum site for vb
This is my first post on this site
If this post= usefull to you
Then click on "This post was helpful !"
Else click on "reply"
End If