SolarCoasters
07-17-2003, 08:52 PM
I want to check each character that a user enters into a price textbox and i want to make sure they don't enter the $ sign. I have the code that alerts them to only enter numbers but the $ character still gets added how can I make sure that it can't be added at all?
Private Sub Text1_Change()
If InStr(1, Text1.Text, "$") Then SendKeys "{Backspace}"
End Sub
gundavarapu
07-17-2003, 10:30 PM
or try this.
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 36 Then KeyAscii = 0
End Sub
Regards,
Sidhu
manavo
07-18-2003, 04:17 PM
Private Sub Text1_Change()
If InStr(1, Text1.Text, "$") Then SendKeys "{Backspace}"
End Sub
I don't think this would work as you can change the text property through code (that also fires the change event) which means the control might not have focus.