VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Validate Date

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.

Rate Validate Date

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

Download this snippet    Add to My Saved Code

Validate Date Comments

No comments have been posted about Validate Date. Why not be the first to post a comment about Validate Date.

Post your comment

Subject:
Message:
0/1000 characters