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 Comine two numbers, not addition.

How to Comine two numbers, not addition.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helplearning
12 Posts 5 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Please help me. i am a MFC beginner , and i don't know how to combine two numbers in a dialog box. for example: when a and b are entered into Box1 and Box2, In Box3 will show "ab", NOT "a+b" . Please........HELP.

    A J M 3 Replies Last reply
    0
    • A Anonymous

      Please help me. i am a MFC beginner , and i don't know how to combine two numbers in a dialog box. for example: when a and b are entered into Box1 and Box2, In Box3 will show "ab", NOT "a+b" . Please........HELP.

      J Offline
      J Offline
      JoeZhang
      wrote on last edited by
      #2

      hey, guy, try this... :) ... char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 ... hope this helps! ;)

      A 1 Reply Last reply
      0
      • A Anonymous

        Please help me. i am a MFC beginner , and i don't know how to combine two numbers in a dialog box. for example: when a and b are entered into Box1 and Box2, In Box3 will show "ab", NOT "a+b" . Please........HELP.

        A Offline
        A Offline
        Anthony_Yio
        wrote on last edited by
        #3

        using CString + operator Eg. CString str = atoi(YourInteger); str += "2"; Sonork 100.41263:Anthony_Yio

        A 1 Reply Last reply
        0
        • J JoeZhang

          hey, guy, try this... :) ... char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 ... hope this helps! ;)

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 This doesn't work for me. What is char szA[100], szB[100], szC[200];? Should I use Cstring for BOX3?

          J R A 3 Replies Last reply
          0
          • A Anonymous

            char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 This doesn't work for me. What is char szA[100], szB[100], szC[200];? Should I use Cstring for BOX3?

            J Offline
            J Offline
            JoeZhang
            wrote on last edited by
            #5

            How "it doesn't work for you"? what error occurred? szA,szB,szC just are temporary char string variables.

            A 1 Reply Last reply
            0
            • A Anthony_Yio

              using CString + operator Eg. CString str = atoi(YourInteger); str += "2"; Sonork 100.41263:Anthony_Yio

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              using CString + operator Eg. CString str = atoi(YourInteger); str += "2"; Could u explain more on these? I am not able to follow it.

              1 Reply Last reply
              0
              • A Anonymous

                char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 This doesn't work for me. What is char szA[100], szB[100], szC[200];? Should I use Cstring for BOX3?

                R Offline
                R Offline
                RChin
                wrote on last edited by
                #7

                Anonymous wrote: What is char szA[100], szB[100], szC[200];? :omg::omg::omg::omg::omg::omg::omg::omg::omg: I think you need to find yourself a good beginner's C++ book if you need to ask that question. Never mind string concatenation, read up about variable declaration first. Let us walk before we run.


                I Dream of Absolute Zero

                1 Reply Last reply
                0
                • A Anonymous

                  char szA[100], szB[100], szC[200]; int c; printf(szA,"%d",a); //here, a is a int number entered on edit box 1. printf(szB,"%d",b); //here, b is a int number entered on edit box 2. strcpy(szC,szA); strcat(szC,szB); c = atoi(szC); //here, c is the int number you want, just place it into edit box 3 This doesn't work for me. What is char szA[100], szB[100], szC[200];? Should I use Cstring for BOX3?

                  A Offline
                  A Offline
                  Anthony_Yio
                  wrote on last edited by
                  #8

                  Grab some tutorials on CDialog in codeproject. Sonork 100.41263:Anthony_Yio

                  1 Reply Last reply
                  0
                  • J JoeZhang

                    How "it doesn't work for you"? what error occurred? szA,szB,szC just are temporary char string variables.

                    A Offline
                    A Offline
                    Anonymous
                    wrote on last edited by
                    #9

                    No error occurred, but nothing appear in box3

                    J 1 Reply Last reply
                    0
                    • A Anonymous

                      No error occurred, but nothing appear in box3

                      J Offline
                      J Offline
                      JoeZhang
                      wrote on last edited by
                      #10

                      oh, god...:) just attach a CString class variable with your edit box 3, and then make it equal to "szC", and then call UpdateData(FALSE) to make it show in edit box 3... ;P

                      J 1 Reply Last reply
                      0
                      • J JoeZhang

                        oh, god...:) just attach a CString class variable with your edit box 3, and then make it equal to "szC", and then call UpdateData(FALSE) to make it show in edit box 3... ;P

                        J Offline
                        J Offline
                        JoeZhang
                        wrote on last edited by
                        #11

                        and, you can also... attach a int variable with your edit box 3, and then make it equal to c, and then call UpdateData(FALSE) to make it show in edit box 3...

                        1 Reply Last reply
                        0
                        • A Anonymous

                          Please help me. i am a MFC beginner , and i don't know how to combine two numbers in a dialog box. for example: when a and b are entered into Box1 and Box2, In Box3 will show "ab", NOT "a+b" . Please........HELP.

                          M Offline
                          M Offline
                          Michael Pauli
                          wrote on last edited by
                          #12

                          CString cstrMyNumbers(_T("")); cstrMyNumbers.Format(TEXT("%d%d"), a, b); Simple as that :-) Regards, Michael Mogensen, mm it-consult dk. ><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>

                          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