Search Tools Links Login

Validate Date


Checks and makes sure that the user enters in a valid date. Make a text box on a form and call it txtDate

Original Author: Michael Powers

Assumptions

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.

Code

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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 80 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.