Hi
I have the following code which accepts numbers 0-9 in a textbox.
However, the default value is 0 and if you try to type numbers to the RIGHT of the zero (other than 0 again) it will allow it "01111". I don't want it to do that, I want that if you start to type a number other than zero, it changes the value to the first number you type.
So if default value is "0" and then you type a "1" to the RIGHT of the zero, it changes the whole textbox value to 1 and then allows you to continue typing numbers.
Thanks in advance for your help.
I have the following code which accepts numbers 0-9 in a textbox.
Code:
Private Sub txtb_Amount_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0")
If txtb_Amount.Value = 0 Then KeyAscii = 0
Case Asc("1") To Asc("9")
Case Else
KeyAscii = 0
End Select
End Sub
However, the default value is 0 and if you try to type numbers to the RIGHT of the zero (other than 0 again) it will allow it "01111". I don't want it to do that, I want that if you start to type a number other than zero, it changes the value to the first number you type.
So if default value is "0" and then you type a "1" to the RIGHT of the zero, it changes the whole textbox value to 1 and then allows you to continue typing numbers.
Thanks in advance for your help.