by Michael Powers (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Checks and makes sure that the user enters in a valid date. Make a text box on a form and call it txtDate
Assumes
I made this in a few minutes, after looking for a simple code so that I can make sure that if the user enters in bogus or an incorect form it will either clear it and throw a message or correct it and allow it to pass.
sub validDate()
If txtDate.Text <> "" Then
If IsDate(txtDate) = False Then
MsgBox "You have entered an Invalid Date in Last Contacted please use MM/DD/YYYY", , "Invalid Entry"
txtDate.text= ""
Else
txtDate.Text = Format(txtDate.Text, "General Date")
End If
Else
txtDate.Text = Date
End If
end sub