Declaring a textbox as int?

Posted on 2006-05-09
Last Modified: 2010-04-24

I am using Visual C++ 2005. I have a form with a textbox control. This text box accepts only Text by default.

How can I change its data type to int or float?

Thank you in advance!
Question by:Mahmoodaman
    1 Comment
    LVL 49

    Accepted Solution

    In the dialog editor, right-click the text box and and select Properties.

    Under the Styles tab, but a check in the Number checkbox (lower left)

    Press Ctrl +W to bring up the Classwizard for the parent dialog.

    Under the Member Variables tab, look for the ID of that edit box (it may be IDC_EDIT1).  Click it and then clcik [Add Variable].  

       Member Name:: m_nTheNumber
       Category: Value
       Variable Type: UINT (or "long" if you want to allow input of negative numbers)

    You are done.

    Now, whenever you need to learn what the user has typed in there, you can do:

        UpdateData( TRUE );
        if ( m_nTheNumber > 1000 ) {
            ... ta da...

    -- Dan

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    DLL Windows equivalent in MAC OS 8 108
    Error when running VS apps 14 113
    Visual Studio 2010 C++ Import Typelib Problem 3 279
    SHA256 Code Signing 2 111
    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now