integer-input ONLY textbox in GUI c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenneth6
    New Member
    • Mar 2007
    • 79

    integer-input ONLY textbox in GUI c++

    How can I restrict the textbox in GUI C++ to integer-input ONLY ?

    bcoz the function inside can only process int input parameter.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    What GUI are you using?

    Comment

    • kenneth6
      New Member
      • Mar 2007
      • 79

      #3
      Originally posted by Banfa
      What GUI are you using?
      MSVC++ 2005 Windows Form Application

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        I'm not familiar with Microsoft C++, but if you take the input, you can check each character via the isdigit() function and if any aren't integers, you can clear it and tell the user to reenter.

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Use a masked text box, you can set the mask to only allow digit input

          Comment

          • kenneth6
            New Member
            • Mar 2007
            • 79

            #6
            Originally posted by Banfa
            Use a masked text box, you can set the mask to only allow digit input

            thanks! but how can i set the user-input value be 4-digit ONLY in the masked text box??

            another similar question: how to set the user-input shown to be asterisks (like password box)?

            Comment

            • Studlyami
              Recognized Expert Contributor
              • Sep 2007
              • 464

              #7
              One of the properties of the text-box should say something like password. change the value from false to true. As far as limiting only 4 digits i don't know of a way to limit that. You may just have to let them type what ever they want and then perform a check to see if there is more than 4 digits or not.

              Comment

              • kenneth6
                New Member
                • Mar 2007
                • 79

                #8
                Originally posted by Banfa
                Use a masked text box, you can set the mask to only allow digit input
                but how to use masked text box to allow digit input only ?

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  Originally posted by kenneth6
                  but how to use masked text box to allow digit input only ?
                  In the property list for a masked text box there is property Mask set this to the mask of your input data.

                  You can read about masks here.

                  Comment

                  Working...