Results 1 to 9 of 9

Thread: [Resolved] MFC: "Please enter a number?"

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Question [Resolved] MFC: "Please enter a number?"

    I'm working in an MFC application (my first time), and whenever I erase the contents of my EditBox, or enter a non-numeric character, I get a messagebox saying "Please enter a number."

    How can I get rid of this?
    Last edited by The Hobo; Mar 25th, 2003 at 04:21 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    r u using UpdateData(TRUE) instead of UpdateData(FALSE)
    also check to make sure the variable u have linked to it is string or cstring
    Last edited by dis1411; Mar 25th, 2003 at 12:19 AM.

  3. #3
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    I think I read somewhere that there's a checkbox in the EditBox's properties that checks to make sure everything entered is a number. Make sure that checkbox is not selected
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by dis1411
    r u using UpdateData(TRUE) instead of UpdateData(FALSE)
    also check to make sure the variable u have linked to it is string or cstring
    Yes, I'm using UpdateData(TRUE), but I'm using float for the type? Can I not do that?

    Originally posted by McCain
    I think I read somewhere that there's a checkbox in the EditBox's properties that checks to make sure everything entered is a number. Make sure that checkbox is not selected
    I can't find anything like it?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Well, how can I convert a CString to a float?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Via atof.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    How would I do that? This doesn't seem to work:

    Code:
    void CVGRTaxDlg::OnButtCalc() {
    
        MyTax.SetTaxableIncome(atof(m_IncomeAmount));
        m_iTaxAmount = MyTax.GetTaxAmount();
    		
        CVGRTaxDlg::OnChangeEditTax();
    
    }
    The application compiles but crashes.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Nevermind. The crash was being caused elsewhere

    Here's what I'm using:

    Code:
    MyTax.SetTaxableIncome(static_cast<float>(atof(m_IncomeAmount)));
    And it works great. Thanks.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There are two additional options: an istringstream or the boost lexical_cast.

    www.boost.org
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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