Results 1 to 8 of 8

Thread: numbers

  1. #1

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66
    I have this textbox as a user input. How do I check if
    there's a number in the textbox, and no letters?
    To VB or not to VB, that's the question...

  2. #2
    Hyperactive Member
    Join Date
    Nov 2000
    Location
    Mexico City
    Posts
    306

    Talking

    Try the isnumeric function.

    If isnumeric(text1.text) then
    If things were easy, users might be programmers.

  3. #3

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66
    I already figured that out... but thanx anyway :-)
    To VB or not to VB, that's the question...

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'in declarations:
    option compare text
    
    If isnumeric(text1) then 'it contains a numeric value
    If text1 like "#" then 'it contains a number
    if text1 like "*[!A-Z]*" then 'it contains no letters
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    There's 2 other possibilities.
    Code:
    If Text1 like "*.*" Then     'it contains a decimal
    If Text1 like "*-*" Then     'negative numbers

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey Keda, now don't get sloppy my boy

    Code:
    If text1 like "#" then 'will only fire if there is only one number :) (like if string = "2", NOT string = "h280q821")
    
    If text1 like "*#*" then 'this, instead, will fire if there's a number in the string (like if string = "h280q821")
    I wonder where you were, not online my friend (ICQ).
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    400
    One annoying thing about IsNumeric:
    Code:
    ?IsNumeric("$-6.0e-4")
    True

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Gives me false, remove the "$" and it should give true, thats because -6.0e-4 is expressed as a floating point. -6*10^(-4) which is -0.0004

    yeah jop smart-ass! i was thinking about a number as one number. I'm online right now, but youre not



    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width