To allow a space in front of after the number you can modify the check If Is Numeric(Trim(Text Box82)) = true Then However, I often like to apply both preventive and corrective measures when I validate data.By preventive, I mean show the format or show default values.Numeric Up Down, numeric Up Down1, Hold the number value.Button Click: Once the button is clicked, we first want to create a new integer variable and set it equal to the value of the numericupdown control...ahmedilyas you could use the Mod operator like so: if my Number Mod 2 = 0 then Message Box.
For example, the Is Numeric function incorrectly considers these strings as valid numbers: 123,,,123 345- 34 ' What if it isn't a currency field?Unfortunately, Visual Basic's Text Box controls offer a default edit menu that lets users perform any clipboard operation by simply right-clicking on them. You might wonder why you also need to trap the Key Up, Mouse Down, and Mouse Move events: The reason is that you always need to keep track of the last valid position for the insertion point because the end user could move it using arrow keys or the mouse.Fortunately, there's a way around this problem: Instead of trapping a key before it gets to the Text Box control, you trap its effect in the Change event and reject it if it doesn't pass your test. Sel Start End Sub Private Sub Text1_Change() ' Avoid nested calls. The preceding code snippet uses the Is Numeric function to trap invalid data.What you really need is a bullet-proof method to trap invalid values. Sel Start = save Sel Start End If End Sub Private Sub Text1_Key Up(Key Code As Integer, Shift As Integer) save Sel Start = Text1.Before I offer you a decent solution to the problem, let me explain why you can't rely solely on trapping invalid keys for your validation chores. Sel Start End Sub Private Sub Text1_Mouse Down(Button As Integer, _ Shift As Integer, X As Single, Y As Single) save Sel Start = Text1.to revalidate if its whole number then he can use abs() i guess Dim x As Integer x = Input Box("Enter integer") If x = Int(x) Then Msg Box "integer" Else Msg Box "not integer" End If I'm just not sure if he means the vb integer (can have decimals), or the mathematical integer (no decimals) so thats all Im saying.