Jump to content
Sign in to follow this  
san1

MaskedTextBox function and KeyPress restricted user entry

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...