Hi
I need to use the KeyPress event to restrict date to MM/DD/YYYY format only. Here's my code:
Private Sub txtDoj_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDoj.KeyPress
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not e.KeyChar = "." Then
e.Handled = True
End If
I understand that this code allows numbers only. But I do not know how to modify this to allow date format only.
Thanks in advance for helping me out.
I need to use the KeyPress event to restrict date to MM/DD/YYYY format only. Here's my code:
Private Sub txtDoj_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDoj.KeyPress
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) And Not e.KeyChar = "." Then
e.Handled = True
End If
I understand that this code allows numbers only. But I do not know how to modify this to allow date format only.
Thanks in advance for helping me out.