roipatrick
New Member
- Joined
- Mar 20, 2014
- Messages
- 39
I need help on how to subtract two military time in vba.
Here's how i grab the start time
Here's how I end the time
As you can see I call a compute procedure, Here's the procedure
It keep returning me this result "12:00:00 AM"
Where did i do wrong ?
Thanks in advance for the help
Here's how i grab the start time
Code:
Sub Start_Timer_Button() 'Call Clear
Worksheets("Control Panel").Cells.Locked = False
Range("L16").Value = Time
Worksheets("Control Panel").Range("L16").Locked = True
Worksheets("Control Panel").Protect Password:="Str0ngp@ssw0rd", UserInterfaceOnly:=True
End Sub
Here's how I end the time
Code:
Sub Stop_Timer_Button() Worksheets("Control Panel").Cells.Locked = False
Range("L18").Value = Time
Worksheets("Control Panel").Range("L16").Locked = True
Worksheets("Control Panel").Range("L18").Locked = True
Worksheets("Control Panel").Protect Password:="Str0ngp@ssw0rd", UserInterfaceOnly:=True
Call Compute
End Sub
As you can see I call a compute procedure, Here's the procedure
Code:
Sub Compute() Dim x As Date
Dim y As Date
Dim t As Date
x = Worksheets("Control Panel").Range("L18").Value
y = Worksheets("Control Panel").Range("L16").Value
MsgBox CDbl(TimeValue(x)) * 24
MsgBox CDbl(TimeValue(y)) * 24
zoo = x - y
t = zoo / 24
MsgBox "d = " & d & vbLf & "t = " & t
End Sub
It keep returning me this result "12:00:00 AM"
Where did i do wrong ?
Thanks in advance for the help