For validating date values, specify the exact date format you are expecting
for ParseExact.
"ABB" <AB*@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
Hi
I tested the solution by replacing 'null' with 'nothing'.
Try passing atimestring as " :" and u will get an exception.
how will this routine work for any invalid string date in atimestring?
ABB
"Siva M" wrote:
This is one way to do it:
Private Function GetValidTime(ByVal atimestring As String) As String
Try
DateTime dt = DateTime.ParseExact (atimestring, "HH:mm", null);
Return atimestring
Catch
Return "00:00"
End Try
End Function
"ABB" <AB*@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
Private Function GetValidTime(ByVal atimestring As String) As String
I am writing a function that accepts a string that may contains a time in
format "HH:MM" or it may contain junk data.
How can I check whether the string passed in this function is a valid
time.
The function should return a valid time string otherwise it returns
"00:00"
in case if invalid timestring was passed.
How can I write that function?
ABB