Numbers only please...

Nov 12, 2003 6 Replies

"Please enter a number between 1 and 100000"



Come on! Make it impossible to enter a character other than a number. Is that so hard? Or is there a reason for?


if not number < 1 and not number > 100000 then

msgbox "your number is greater the 1 and less then 100000"

else

msgbox "your number is not greater the 1 or not less then 100000"

end if

Down With Polite Software!

I hate when they put please in there to somehow make you feel better for the anemic way in which the box accepts numbers.

Agreed-

SMA

OT: Are you CountZero[BOX] from Q2?

you need at least some non-numeric characters--

1.0 1.0 in 1.0 mm 87mm - 1.05 in

are all valid inputs

I have used: ... On Error GoTo EntryError ... Num = CInt(Entered_Value) ... Exit Sub EntryError: Messages = "Error: Only numbers allowed, try again" ... End Sub

Of-course you can modify the code to take care of the mm/in/m/cubits part of the entered text. Much more sophisticated possibilities are possible with C++ etc...

Regards,

mvk

If Q2 means Quake2, yes, that was (is) my alias. From the text adventure "Count Zero" in DOS, waaaaayyy back.

' I use something like the following: Private Sub Text1_KeyPress(KeyAscii As Integer) NumericChars = Array(8, 43, 45, 46, 48, 49, 50, 51, 52, 53, 54,

55, 56, 57) For I = 0 To UBound(NumericChars) If NumericChars(I) = KeyAscii Then Exit Sub Next I KeyAscii = 0 End Sub

I can then use different 'filters' depending on what I want to allow the users to enter into the textbox

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required