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. String concatenation in vc++.net

String concatenation in vc++.net

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++tutorialquestion
6 Posts 4 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.
  • S Offline
    S Offline
    salaikumar
    wrote on last edited by
    #1

    hi.. this piece of code is from vc++.net MessageBox(0, "Please Check Row No:" + j ,"Validations",MB_OK); When i try to concatenate some text string with an integer value(j), it compiles successfully. but the output is confusing.. for example..if the value of j is 5, then it trim 5 chars from the left in hat text string.. SO i tried it with concat function...like this.. MessageBox(0, String::Concat("Please Check Row No:" , (Datagrid1->get_Item(j,0))) ,"Validations",MB_OK); This returns error "error C2665: 'System::String::Concat' : none of the 9 overloads can convert parameter 2 from type 'System::Object __gc *'" Can anyone solve my problem? Salai

    R 1 Reply Last reply
    0
    • S salaikumar

      hi.. this piece of code is from vc++.net MessageBox(0, "Please Check Row No:" + j ,"Validations",MB_OK); When i try to concatenate some text string with an integer value(j), it compiles successfully. but the output is confusing.. for example..if the value of j is 5, then it trim 5 chars from the left in hat text string.. SO i tried it with concat function...like this.. MessageBox(0, String::Concat("Please Check Row No:" , (Datagrid1->get_Item(j,0))) ,"Validations",MB_OK); This returns error "error C2665: 'System::String::Concat' : none of the 9 overloads can convert parameter 2 from type 'System::Object __gc *'" Can anyone solve my problem? Salai

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #2

      Use CString object: CString str; str.Format("Please Check Row No: %d Validations",j); MessageBox(0,str,MB_OK); Matteo

      S 1 Reply Last reply
      0
      • R Russell

        Use CString object: CString str; str.Format("Please Check Row No: %d Validations",j); MessageBox(0,str,MB_OK); Matteo

        S Offline
        S Offline
        salaikumar
        wrote on last edited by
        #3

        Maetto.. Thanks for yr reply.. i tried this... But it returns error "CString : Undeclared identifier." i put this code in .cpp file... should i have to include any header files here? Salai

        B J R 3 Replies Last reply
        0
        • S salaikumar

          Maetto.. Thanks for yr reply.. i tried this... But it returns error "CString : Undeclared identifier." i put this code in .cpp file... should i have to include any header files here? Salai

          B Offline
          B Offline
          BambooMoon
          wrote on last edited by
          #4

          > CString str; > str.Format("Please Check Row No: %d Validations",j); > MessageBox(0,str,MB_OK); > But it returns error "CString : Undeclared identifier." char szBuf[200]; sprintf(szBuf, "Please Check Row No: %d Validations", j); MessageBox(0, szBuf, MB_OK);

          1 Reply Last reply
          0
          • S salaikumar

            Maetto.. Thanks for yr reply.. i tried this... But it returns error "CString : Undeclared identifier." i put this code in .cpp file... should i have to include any header files here? Salai

            J Offline
            J Offline
            James R Twine
            wrote on last edited by
            #5

            Never go heavyweight when lightweight works fine: TCHAR caBuffer[ 64 + 1 ]; _snprintf( caBuffer, 64, "Please Check Row No: %d Validations", j ); caBuffer[ 64 ] = '\0'; MessageBox( NULL, "Example", caBuffer, MB_OK );    Peace! -=- James


            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            DeleteFXPFiles & CheckFavorites (Please rate this post!)

            1 Reply Last reply
            0
            • S salaikumar

              Maetto.. Thanks for yr reply.. i tried this... But it returns error "CString : Undeclared identifier." i put this code in .cpp file... should i have to include any header files here? Salai

              R Offline
              R Offline
              Russell
              wrote on last edited by
              #6

              CString is defined in "cstringt.h" (MFC) or "atlstr.h" (NON-MFC)

              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