Jump to content

MaskedTextBox function and KeyPress restricted user entry


san1

Recommended Posts

HiI have the following code. I need to test an entry in the textbox to check if entry is a valid date.- I would like to use the MaskedTextBox function in this click event and then limit the entry to date only in the KeyPress event.Private Sub CheckDate_Validating(sender As Object, e As EventArgs) Handles CheckDate.MouseClickDim dt As String = DateTime.NowFormat(dt, "MM/dd/yy")' Configure the message box to be displayedDim messageBox1Text As String = "is Not a valid date"Dim messageBox2Text As String = "IS a valid date"If Date.TryParseExact(txtDoj.Text.ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture, Globalization.DateTimeStyles.None, dt) Then' Display message boxMessageBox.Show(messageBox2Text)Else' Display message boxMessageBox.Show(messageBox1Text)EndEnd IfEnd SubPrivate Sub txtDoj_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDoj.KeyPressEnd SubPlease help. Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...