Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to check string if its Date or not 1

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
0
0
US
I have an InputBox that pops up and asks for entering Date or a Text. I want to have an If Then Else that checks if the value passed is Date or a string. If its a date, then I need to change the format and then insert it into a table. I have the insert statements and everything else is working, except how to check if the string is date.
Any ideas? For example, if someone types 'xyzabcdef', how would I check if that string is a Date or not?

Dim strDate as String
strDate = InputBox("Please enter date.",Pay Date")

If strDate = DATE (need to check here like this) Then
strDate = Format(strDate,"mm-dd-yy")
End If
 
Code:
If IsDate(strDate) Then
   strDate = Format(strDate,"mm-dd-yy")
End If

Trevor
 
Thanks. That was exactly what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top