B
Bob Barnes
Does anyone have code to allow entry of ONLY one Decimal Point (KeyAscii
Character 46) in a text box???
I was playing w/ code like this, but NOT getting the desired result.
Public Sub DecZeroNine(KeyAscii)
Dim B, Ctl As Control
Set Ctl = Screen.ActiveControl
MsgBox Screen.ActiveControl
If ((KeyAscii = 8) Or _
(KeyAscii >= 48 And KeyAscii <= 57)) Then
' it's a 0-9 or a Backspace (8)
ElseIf (KeyAscii = 46) Then
MsgBox KeyAscii
' it's ar Decimal Pt (46)
B = InStr(1, Ctl, ".")
MsgBox B
If IsNull(B) Then
MsgBox "Null"
' OK - 1st "."
Else
MsgBox "No DecPt Allowed"
KeyAscii = 0
End If
Else
' eat it
KeyAscii = 0
End If
End Sub
TIA - Bob
Character 46) in a text box???
I was playing w/ code like this, but NOT getting the desired result.
Public Sub DecZeroNine(KeyAscii)
Dim B, Ctl As Control
Set Ctl = Screen.ActiveControl
MsgBox Screen.ActiveControl
If ((KeyAscii = 8) Or _
(KeyAscii >= 48 And KeyAscii <= 57)) Then
' it's a 0-9 or a Backspace (8)
ElseIf (KeyAscii = 46) Then
MsgBox KeyAscii
' it's ar Decimal Pt (46)
B = InStr(1, Ctl, ".")
MsgBox B
If IsNull(B) Then
MsgBox "Null"
' OK - 1st "."
Else
MsgBox "No DecPt Allowed"
KeyAscii = 0
End If
Else
' eat it
KeyAscii = 0
End If
End Sub
TIA - Bob