sassriverrat
Well-known Member
- Joined
- Oct 4, 2018
- Messages
- 655
Good Morning,
A user made this (and I just contributed) probably a year ago and I've been fighting a bug in it. I have a userform that inputs data (in a halfway pretty GUI) in appropriate cells on a sheet. The user is supposed to be able to input, say, 0900, 9:00, or any "theoretical" method of typing in a time into the userform or into the cell itself and it should be corrected to a properly formatted time. Well it seems that inputting, say 0412 or 0400, certain times work fine, yet if start to input 090, the code below errors twice in a row here, regardless of what the last digit might be in an attempt to input 0900. And after denying the error twice, when I input the last 0, so 0900, it will error a third time. Not sure why this specific time does it, but it is consistent!
A user made this (and I just contributed) probably a year ago and I've been fighting a bug in it. I have a userform that inputs data (in a halfway pretty GUI) in appropriate cells on a sheet. The user is supposed to be able to input, say, 0900, 9:00, or any "theoretical" method of typing in a time into the userform or into the cell itself and it should be corrected to a properly formatted time. Well it seems that inputting, say 0412 or 0400, certain times work fine, yet if start to input 090, the code below errors twice in a row here, regardless of what the last digit might be in an attempt to input 0900. And after denying the error twice, when I input the last 0, so 0900, it will error a third time. Not sure why this specific time does it, but it is consistent!
Code:
Function MilitarytoTime(Miltime As String) As Date
'Begins Error Handling Code
On Error GoTo Helper
If Miltime <> "" Then
MilitarytoTime = Format(Replace(Miltime, ":", ""), "00:00")
End If
'Error Clearing Code
Exit Function
Helper:
resp = MsgBox("We're sorry to see you've encountered an error." & vbCrLf & vbCrLf & "To proceed, we recommend you contact the Developer " & _
"with error codes [1131] and " & "[" & Err.Number & "-" & Err.Description & "]." & vbCrLf & vbCrLf & "To attempt to patch your problem at least " & _
"temporarily, we recommend you click [Yes] to see help directions. Would you like to continue?", vbYesNoCancel, name)
If resp = vbYes Then
Call Error_Handle(sprocname, Err.Number, Err.Description)
ElseIf resp = vbNo Then
Exit Function
ElseIf resp = vbCancel Then
Exit Function
End If
End Function