Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to control data from edit box

How to control data from edit box

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trupti Mehta
    wrote on last edited by
    #1

    I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.

    Thanks Terry

    S R H 3 Replies Last reply
    0
    • T Trupti Mehta

      I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.

      Thanks Terry

      S Offline
      S Offline
      Schehaider_Aymen
      wrote on last edited by
      #2

      try to use a CString var in which u read the text typed. and then use the atoi() funct/. such : CString TXT; int Nbr; m_EditContr.GetWindowText(TXT); if (TXT.IsEmpty()!=0) Nbr.atoi(TXT); But when the user type such thing (ASD45O) it may not work. !!!

      "The Ultimate Limit Is Only Your Imagination."

      J 1 Reply Last reply
      0
      • T Trupti Mehta

        I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.

        Thanks Terry

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        Add a control variable to your edit box, may it be c_Edit. You can use this variable to get the text entered in your edit box by calling c_Edit.GetWindowText(). This function will always return an LPTSTR. You can use conversion functions like _ttoi() just in case you need numbers. Here are some tutorials which may help you: CEdit Tutorial 1[^] CEdit tutorial 2[^] CEdit tutorial 3[^] I also suggest that you read a good book on MFC (well, if you are using MFC) and on Win32.

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        1 Reply Last reply
        0
        • S Schehaider_Aymen

          try to use a CString var in which u read the text typed. and then use the atoi() funct/. such : CString TXT; int Nbr; m_EditContr.GetWindowText(TXT); if (TXT.IsEmpty()!=0) Nbr.atoi(TXT); But when the user type such thing (ASD45O) it may not work. !!!

          "The Ultimate Limit Is Only Your Imagination."

          J Offline
          J Offline
          Jijo Raj
          wrote on last edited by
          #4

          Blood_HaZaRd wrote:

          Nbr.atoi(TXT);

          or

          Nbr = atoi(TXT);

          Typo? ;) Regards, Jijo.

          _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

          S 1 Reply Last reply
          0
          • J Jijo Raj

            Blood_HaZaRd wrote:

            Nbr.atoi(TXT);

            or

            Nbr = atoi(TXT);

            Typo? ;) Regards, Jijo.

            _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

            S Offline
            S Offline
            Schehaider_Aymen
            wrote on last edited by
            #5

            LOL, yup it was a typo mistake :p

            "The Ultimate Limit Is Only Your Imagination."

            N 1 Reply Last reply
            0
            • T Trupti Mehta

              I have edit boxes, which accept int, float, date & CString. If i check Style-Number of EditBox Number & retrive data via member variable associated with the control, I get some junk chars only or an empty string. How can I get data and convert it back to int, float or date respectively. Any guidance, examples, etc will be of great help & highly appreciated.

              Thanks Terry

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Trupti Mehta wrote:

              How can I get data and convert it back to int, float or date respectively

              You can use of GetWindowText and then see CString::Format.

              1 Reply Last reply
              0
              • S Schehaider_Aymen

                LOL, yup it was a typo mistake :p

                "The Ultimate Limit Is Only Your Imagination."

                N Offline
                N Offline
                Nelek
                wrote on last edited by
                #7

                Then edit your answer... or are you lazy? :P

                Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups