robertrobert905
Board Regular
- Joined
- Jun 27, 2008
- Messages
- 139
Hi I found a function the internet that works with vba which will only allow a numerical input from a control (textbox for my case)
When i tested the code, I get the popup if I enter a number and then try to delete or backspace it. But if I try to enter a letter I would get the popup twice in a row. How can I fix this problem?
When i tested the code, I get the popup if I enter a number and then try to delete or backspace it. But if I try to enter a letter I would get the popup twice in a row. How can I fix this problem?
Code:
Function OnlyNumbers(ControlNames As Control)
If ControlNames.Value < 0 Or ControlNames.Value > 99999 Then
ControlNames.Value = ""
MsgBox ("Invalid input, only numerical input is allowed!")
End If
End Function