Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27532

VS 2012 Use the KeyPress event to restrict user entry for date format

$
0
0
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.

Viewing all articles
Browse latest Browse all 27532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>