Numbers only please...

Discussion in 'SolidWorks' started by Count Zero, Nov 12, 2003.

  1. Count Zero

    Count Zero Guest

    "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?
     
    Count Zero, Nov 12, 2003
    #1
  2. 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
     
    Sean Phillips, Nov 12, 2003
    #2
  3. 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?
     
    Sean-Michael Adams, Nov 12, 2003
    #3
  4. Count Zero

    Michael Guest

    you need at least some non-numeric characters--

    1.0
    1.0 in
    1.0 mm
    87mm - 1.05 in

    are all valid inputs
     
    Michael, Nov 12, 2003
    #4
  5. 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
     
    Vinodh Kumar M, Nov 13, 2003
    #5
  6. Count Zero

    Count Zero Guest

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

    rocheey Guest

    I have used:

    ' 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
     
    rocheey, Nov 13, 2003
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.