I have this function which will accept a time as string
Public Shared Function SpecTime(ByVal timeStr As String) As String
Dim dt As DateTime
If String.IsNullOrEmpty(timeStr) Then
Return ""
Else
Try
dt = DateTime.Parse("1/8/1985 " + timeStr)
Catch ex As Exception
'catches a FormatException
End Try
Return dt.ToString("h:mm tt")
End If
End Function
when i input an invalid time str eg. "1a", how do i know the unique code for that specific exception? how will it know that "12 a" is invalid or "12;00" is invalid???
my point here is that i need to know the unique exception code (if there is any) so i could handle the different exceptions accordingly.
tnx!
Public Shared Function SpecTime(ByVal timeStr As String) As String
Dim dt As DateTime
If String.IsNullOrEmpty(timeStr) Then
Return ""
Else
Try
dt = DateTime.Parse("1/8/1985 " + timeStr)
Catch ex As Exception
'catches a FormatException
End Try
Return dt.ToString("h:mm tt")
End If
End Function
when i input an invalid time str eg. "1a", how do i know the unique code for that specific exception? how will it know that "12 a" is invalid or "12;00" is invalid???
my point here is that i need to know the unique exception code (if there is any) so i could handle the different exceptions accordingly.
tnx!