06-04-14, 12:44 AM
كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.MaxLength = 10
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If ((Not Char.IsControl(e.KeyChar)) AndAlso (Not Char.IsNumber(e.KeyChar)) AndAlso (Not ((TextBox1.TextLength = 2) AndAlso (e.KeyChar = "/"c)))) OrElse (Char.IsNumber(e.KeyChar) AndAlso (TextBox1.TextLength = 2)) Then
e.Handled = True
End If
End Sub
End Class
