|
-
January 12th, 2000, 05:45 AM
#1
Filter Input to Textbox Within an ActiveX Control
I have a Textbox control within an ActiveX Control. I wish any input to the textbox to be numeric only. A decimal point is permitted but only once. The following code is included in my Textbox keypress event:
Private Sub txtValue_KeyPress(KeyAscii As Integer)
'Allow the backspace key to pass through but only allow the
'decimal point key to pass through if it isn't in the string already...
If KeyAscii = 46 And InStr(txtValue.Text, ".") = 0 Or KeyAscii = 8 Then
Exit Sub
'Only update if the Enter Key is Pressed...
Else
'Only let number keys through...
If KeyAscii < 48 Or KeyAscii > 57 Then
'MsgBox "Numeric Input Only...!", vbOKOnly, "Numeric Input Error"
KeyAscii = 0
End If
End If
End Sub
This code appears to work fine in a textbox on its own. Problem is it gives bizarre results and does not accept a decimal point when included in my control!!!
Any pointers would be much appreciated...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|