Results 1 to 8 of 8

Thread: [RESOLVED] numbers in text boxes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Location
    Guernsey, UK
    Posts
    104

    Resolved [RESOLVED] numbers in text boxes

    i have 3 text boxes and am using them to do a simple subtraction between them. The problem is when I input a non-numerical character, i get a type-mismatch error. How can I get around this?


    Thanks,

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: numbers in text boxes

    Try a search, this is a very common question.

  3. #3

  4. #4
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: numbers in text boxes

    if you use val(text1.text) or whatever, it returns a legal integer no matter what. Non-numeric entries after a numeric entry (example: 123fg) are ignored and this example would end up being 123. and if it is non-numeric ONLY ("lord") then it returns a zero. Seems like a better idea though would be to limit the text inputted. And make sure you take into account copy/paste operations also.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: numbers in text boxes

    Remember Val is not locale aware. Less than half of the countries of the world use the dot as a decimal separator.

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: numbers in text boxes

    true...
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Location
    Guernsey, UK
    Posts
    104

    Re: numbers in text boxes

    Fortunately, whole numbers are expected in this application. However, how could decimal indicators be allowed?

    Thanks,

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: numbers in text boxes

    Quote Originally Posted by atanq
    Fortunately, whole numbers are expected in this application. However, how could decimal indicators be allowed?

    Thanks,
    If you compile and use my control you will be able to use two new properties with which you can define if the NuberBox will allow decimals and if it does you can specify how many decimals.

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