Hello,
I am trying to create a Function to test TextBoxes and convert the Text to
DateTime if not empty.
My code is :
Public Shared Function GetDateTime(ByV al DateValue As String) As String
If Not String.IsNullOr Empty(DateValue ) Then
Return DateTime.Parse( DateValue)
Else
Return Nothing
End If
End Function
Then in a OnClick command I have:
CurrentMember.S tartDate = GetDateTime(txt StartDate.Text)
It works ok when there is a date but if its empty I get an error message:
System.InvalidC astException: Conversion from string "" to type 'Date' is not
valid.
If I do CurrentMember.S tartDate = Nothing it works fine so no problem with
Null values in the field.
Does anyone have any suggestions as this has puzzled me for too long now.
Thanks in advance
James
I am trying to create a Function to test TextBoxes and convert the Text to
DateTime if not empty.
My code is :
Public Shared Function GetDateTime(ByV al DateValue As String) As String
If Not String.IsNullOr Empty(DateValue ) Then
Return DateTime.Parse( DateValue)
Else
Return Nothing
End If
End Function
Then in a OnClick command I have:
CurrentMember.S tartDate = GetDateTime(txt StartDate.Text)
It works ok when there is a date but if its empty I get an error message:
System.InvalidC astException: Conversion from string "" to type 'Date' is not
valid.
If I do CurrentMember.S tartDate = Nothing it works fine so no problem with
Null values in the field.
Does anyone have any suggestions as this has puzzled me for too long now.
Thanks in advance
James
Comment