Put in the text 'KeyPress' event to restrict the text boxes to specific keys, upper case, numbers,
Put in the text 'KeyPress' event to restrict the text boxes to specific keys, upper case, numbers, decimals or date. [email protected]
Rate Put in the text 'KeyPress' event to restrict the text boxes to specific keys, upper case, numbers,
(1(1 Vote))
'restrict the text boxes to specific keys,
'upper case, numbers, decimals or date
'Syntax:
' KeyAscii = TextKeyAscii(KeyAscii, vbDouble, Text1.Text)
' KeyAscii = TextKeyAscii(KeyAscii, vbLong)
' KeyAscii = TextKeyAscii(KeyAscii, vbDate)
' KeyAscii = TextKeyAscii(KeyAscii, vbString)
'http://www.geocities.com/dkblid
'mailto:[email protected]
Public Function TextKeyAscii(ByVal KeyAscii As Integer, ByVal KeyType As Integer, Optional ByVal sString As String) As Integer
Dim per As Integer
If KeyAscii < 32 Then
If KeyAscii = 3 Then 'copy
ElseIf KeyAscii = 8 Then 'backspace
ElseIf KeyAscii = 13 Then 'enter
ElseIf KeyAscii = 22 Then 'paste
ElseIf KeyAscii = 24 Then 'cut
ElseIf KeyAscii = 27 Then 'escape
Else
KeyAscii = 0
End If
Else
Select Case KeyType
Case vbLong
If (KeyAscii < 48 Or KeyAscii > 60) Then
KeyAscii = 0
End If
Case vbDouble
If KeyAscii = 46 Then
per = InStr(sString, ".")
If per > 0 Then
KeyAscii = 0
End If
ElseIf (KeyAscii < 48 Or KeyAscii > 60) Then
KeyAscii = 0
End If
Case vbDate
If (KeyAscii < 48 Or KeyAscii > 60) And KeyAscii <> 47 Then
KeyAscii = 0
End If
Case vbString
KeyAscii = IIf(KeyAscii >= 97 And KeyAscii <= 122, KeyAscii - 32, KeyAscii)
End Select
End If
TextKeyAscii = KeyAscii
End Function
Put in the text 'KeyPress' event to restrict the text boxes to specific keys, upper case, numbers, Comments
No comments yet — be the first to post one!
Post a Comment