Hi,
If you are using vb 2005 I would use DateTime.TryParse otherwise
I would use a regex.
http://msdn2.microsoft.com/en-us/lib....tryparse.aspx
Dim dtnow As DateTime
If DateTime.TryParse("1/1/2006", dtnow) Then
Me.Text = dtnow.ToString
End If
Regex example
Dim dtNow As DateTime
Dim strDate As String = "1/1/2006"
Dim regDate As New
System.Text.RegularExpressions.Regex("^\d{1,2}\/\d{1,2}\/\d{4}$")
If regDate.IsMatch(strDate) Then
dtNow = Date.Parse(strDate)
Me.Text = dtNow.ToString
End If
http://www.regexlib.com/Search.aspx?k=date
Ken
---------------------
"YardDancer" <da*********@hotmail.comwrote in message
news:Oi**************@TK2MSFTNGP06.phx.gbl...
Hi All,
Does anybody have a routine for validating a date or DateTime entry in a
textbox.
I know i can use one of the DateTime.Parse(textbox.text) methods which
would throw a Fromat Exception.
What i am after is something like a IsNumeric() fuction or way i can test
a value if it is dateTime value and recieve a boolean answer i.e. true or
false.
Yard Dancer
Practicing at home before I attempt to dance at the hall.