Hi
I'm trying to calculate the difference in times on a userform. I have a start time, pause, continue and end times which are entered using time stamps with the NOW() funtion. I've calculated but it returns an actual "hour" rather than the time difference. I'm completely new at this and now done VBA coding before, please bear with me. Here is the code:
When I transfer the data to the worksheet, the time returns like this instead "27-03-2015 16:19:38" instead of proper calc of minutes taken
I'm trying to calculate the difference in times on a userform. I have a start time, pause, continue and end times which are entered using time stamps with the NOW() funtion. I've calculated but it returns an actual "hour" rather than the time difference. I'm completely new at this and now done VBA coding before, please bear with me. Here is the code:
Private Sub StartButton_Click()
'Inserts the start time and date
'Start time function
Dim BeginTime As Double
BeginTime = Now()
StatsCapture.BeginTimeBox.Value = BeginTime
End Sub
Private Sub PauseButton_Click()
'Inserts the pause time
'Pause time function
'Checks if timer has been started
If StatsCapture.BeginTimeBox.Value = "" Then
MsgBox "Timer has not been started!"
Exit Sub
End If
Dim PausedTime As Double
PausedTime = Now()
StatsCapture.PausedTimeBox.Value = PausedTime
End Sub
Private Sub ContinueButton_Click()
'Inserts the pause time
'Pause time function
'Checks if timer has been started
If StatsCapture.BeginTimeBox.Value = "" Then
MsgBox "Timer has not been started!"
Exit Sub
End If
'Checks if timer has been paused
If StatsCapture.PausedTimeBox.Value = "" Then
MsgBox "Timer is not paused!"
Exit Sub
End If
Dim ContinuedTime As Double
ContinuedTime = Now()
StatsCapture.ContinuedTimeBox.Value = ContinuedTime
End Sub
Private Sub PauseButton_Click()
'Inserts the pause time
'Pause time function
'Checks if timer has been started
If StatsCapture.BeginTimeBox.Value = "" Then
MsgBox "Timer has not been started!"
Exit Sub
End If
Dim PausedTime As Double
PausedTime = Now()
StatsCapture.PausedTimeBox.Value = PausedTime
End Sub
Private Sub ContinueButton_Click()
'Inserts the pause time
'Pause time function
'Checks if timer has been started
If StatsCapture.BeginTimeBox.Value = "" Then
MsgBox "Timer has not been started!"
Exit Sub
End If
'Checks if timer has been paused
If StatsCapture.PausedTimeBox.Value = "" Then
MsgBox "Timer is not paused!"
Exit Sub
End If
Dim ContinuedTime As Double
ContinuedTime = Now()
StatsCapture.ContinuedTimeBox.Value = ContinuedTime
End Sub
'Calculates the duration of the query
Dim Duration As Double
If StatsCapture.BeginTimeBox.Value = "" Then
Duration = ManualTime.Value
Else:
Duration = EndTime + PausedTime - BeginTime - ContinuedTime
End If
Dim Duration As Double
If StatsCapture.BeginTimeBox.Value = "" Then
Duration = ManualTime.Value
Else:
Duration = EndTime + PausedTime - BeginTime - ContinuedTime
End If
When I transfer the data to the worksheet, the time returns like this instead "27-03-2015 16:19:38" instead of proper calc of minutes taken