i am typing below code in each and every date text box keypress event to allow numbers and back slash keys only.
can any function or subroutine be created to avoide typing same code again and again in the project.
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr$(KeyAscii)
If Not ( _
(ch >= "0" And ch <= "9") Or _
KeyAscii = 8 Or _
KeyAscii = 13 Or _
KeyAscii = 84 Or _
KeyAscii = 116 Or _
KeyAscii = 47) Then
' Cancel the character.
KeyAscii = 0
End If
If KeyAscii = 116 Or KeyAscii = 84 Then
KeyAscii = 0
Text1.Text = Date
End If
End Sub