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. COM
  4. Passing 3d string array from VC++ to VB

Passing 3d string array from VC++ to VB

Scheduled Pinned Locked Moved COM
c++data-structures
7 Posts 2 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.
  • G Offline
    G Offline
    georgekjolly
    wrote on last edited by
    #1

    Hi all, I have code for passing 2d array from VC++ to VB6(Code is given below), But My need is to pass a 3d array from VC++ to VB6, Can any one pleas replace the code I have given for 2d to 3d STDMETHODIMP TestMacroInterface::ProcessStringArray(SAFEARRAY**ppOutputArray) { HRESULT hresult; SAFEARRAYBOUND aDim[2] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 2 BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim); if (*ppOutputArray==NULL) { ::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK); } else hresult=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr) pbstr[0][0] = SysAllocString(OLESTR("SOURCE_VA")); pbstr[0][1] = SysAllocString(OLESTR("ACV")); pbstr[0][2] = SysAllocString(OLESTR("10")); SafeArrayUnaccessData(*ppOutputArray); } Thanks George

    P 1 Reply Last reply
    0
    • G georgekjolly

      Hi all, I have code for passing 2d array from VC++ to VB6(Code is given below), But My need is to pass a 3d array from VC++ to VB6, Can any one pleas replace the code I have given for 2d to 3d STDMETHODIMP TestMacroInterface::ProcessStringArray(SAFEARRAY**ppOutputArray) { HRESULT hresult; SAFEARRAYBOUND aDim[2] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 2 BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim); if (*ppOutputArray==NULL) { ::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK); } else hresult=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr) pbstr[0][0] = SysAllocString(OLESTR("SOURCE_VA")); pbstr[0][1] = SysAllocString(OLESTR("ACV")); pbstr[0][2] = SysAllocString(OLESTR("10")); SafeArrayUnaccessData(*ppOutputArray); } Thanks George

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      georgekjolly wrote:

      SAFEARRAYBOUND aDim[2] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 2 BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim); if (*ppOutputArray==NULL) { ::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK); }

      Change this to,

      SAFEARRAYBOUND aDim[3]
      aDim[0].lLbound = 0;
      aDim[0].cElements = 3;
      aDim[1].lLbound = 0;
      aDim[1].cElements = 3
      aDim[2].lLbound = 0;
      aDim[2].cElements = 3

      BSTR HUGEP *pbstr;
      *ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
      if (*ppOutputArray==NULL)
      {

      Prasad Notifier using ATL | Operator new[],delete[][^]

      G 1 Reply Last reply
      0
      • P prasad_som

        georgekjolly wrote:

        SAFEARRAYBOUND aDim[2] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 2 BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim); if (*ppOutputArray==NULL) { ::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK); }

        Change this to,

        SAFEARRAYBOUND aDim[3]
        aDim[0].lLbound = 0;
        aDim[0].cElements = 3;
        aDim[1].lLbound = 0;
        aDim[1].cElements = 3
        aDim[2].lLbound = 0;
        aDim[2].cElements = 3

        BSTR HUGEP *pbstr;
        *ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
        if (*ppOutputArray==NULL)
        {

        Prasad Notifier using ATL | Operator new[],delete[][^]

        G Offline
        G Offline
        georgekjolly
        wrote on last edited by
        #3

        Hi Prasad, Thank you very much. And some more help please .. 1-> How can I pass a 3d array from VB to VC++ ( Just code ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim i As Test33CL Dim iArray(1 To 3, 1 To 3, 1 To 3) As String Private Sub Command1_Click() Set i = New Test33CL i.StringFun (iArray) End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Is there is a riht way , I am getting error. 2-> how to assign string value to BSTR *pbstr. Thanks George

        P 1 Reply Last reply
        0
        • G georgekjolly

          Hi Prasad, Thank you very much. And some more help please .. 1-> How can I pass a 3d array from VB to VC++ ( Just code ) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim i As Test33CL Dim iArray(1 To 3, 1 To 3, 1 To 3) As String Private Sub Command1_Click() Set i = New Test33CL i.StringFun (iArray) End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Is there is a riht way , I am getting error. 2-> how to assign string value to BSTR *pbstr. Thanks George

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          Hi George, I'm not VB guy. Lets wait some body to solve your query.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          G 1 Reply Last reply
          0
          • P prasad_som

            Hi George, I'm not VB guy. Lets wait some body to solve your query.

            Prasad Notifier using ATL | Operator new[],delete[][^]

            G Offline
            G Offline
            georgekjolly
            wrote on last edited by
            #5

            Hai Prasad, Sorry for again disturbing u .. It is an assignment for me from a company ,If I am clearing this I will get Job there... Please Just See my assignment of String to the 3d array is in Right way ,Programme I have given below.. STDMETHODIMP CTestMacroInterface::ProcessStringArray(SAFEARRAY *ppOutputArray) { SAFEARRAYBOUND aDim[3] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 3 aDim[2].lLbound = 0; aDim[2].cElements = 3 HRESULT hr; BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim); if (*ppOutputArray==NULL) { Messagebox("Null"); } else hr=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr /******************************************************************* Now I need to store my data 3 dimensionaly data is FirstName LastName Job Ram Lakhan Engineer Dipu Das Merchant Vinu Lal Bussiness a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer" a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant" a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness" **************************************************************/ // Here I have assigned my values, Is this the correct way of assigning values ?? pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0] pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0] pbstr[2] = SysAllocString(OLESTR("Vinu")); // for a[2][0] pbstr[3] = SysAllocString(OLESTR("Lakhan")); // for a[0][1] pbstr[4] = SysAllocString(OLESTR("Das")); // for a[1][1] pbstr[5] = SysAllocString(OLESTR("Lal")); // for a[2][1] pbstr[6] = SysAllocString(OLESTR("Engineer")); // for a[0][2] pbstr[7] = SysAllocString(OLESTR("Merchant")); // for a[1][2] pbstr[8] = SysAllocString(OLESTR("Bussiness")); // for a[2][2] SafeArrayUnaccessData(*ppOutputArray); } Thanks George

            P 1 Reply Last reply
            0
            • G georgekjolly

              Hai Prasad, Sorry for again disturbing u .. It is an assignment for me from a company ,If I am clearing this I will get Job there... Please Just See my assignment of String to the 3d array is in Right way ,Programme I have given below.. STDMETHODIMP CTestMacroInterface::ProcessStringArray(SAFEARRAY *ppOutputArray) { SAFEARRAYBOUND aDim[3] aDim[0].lLbound = 0; aDim[0].cElements = 3; aDim[1].lLbound = 0; aDim[1].cElements = 3 aDim[2].lLbound = 0; aDim[2].cElements = 3 HRESULT hr; BSTR HUGEP *pbstr; *ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim); if (*ppOutputArray==NULL) { Messagebox("Null"); } else hr=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr /******************************************************************* Now I need to store my data 3 dimensionaly data is FirstName LastName Job Ram Lakhan Engineer Dipu Das Merchant Vinu Lal Bussiness a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer" a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant" a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness" **************************************************************/ // Here I have assigned my values, Is this the correct way of assigning values ?? pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0] pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0] pbstr[2] = SysAllocString(OLESTR("Vinu")); // for a[2][0] pbstr[3] = SysAllocString(OLESTR("Lakhan")); // for a[0][1] pbstr[4] = SysAllocString(OLESTR("Das")); // for a[1][1] pbstr[5] = SysAllocString(OLESTR("Lal")); // for a[2][1] pbstr[6] = SysAllocString(OLESTR("Engineer")); // for a[0][2] pbstr[7] = SysAllocString(OLESTR("Merchant")); // for a[1][2] pbstr[8] = SysAllocString(OLESTR("Bussiness")); // for a[2][2] SafeArrayUnaccessData(*ppOutputArray); } Thanks George

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #6

              georgekjolly wrote:

              a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer" a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant" a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness" **************************************************************/ // Here I have assigned my values, Is this the correct way of assigning values ?? pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0] pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0]

              I think, you have messed up here. Using Arrays of Strings[^]. This link will give you idea, how to use the array.

              Prasad Notifier using ATL | Operator new[],delete[][^]

              G 1 Reply Last reply
              0
              • P prasad_som

                georgekjolly wrote:

                a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer" a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant" a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness" **************************************************************/ // Here I have assigned my values, Is this the correct way of assigning values ?? pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0] pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0]

                I think, you have messed up here. Using Arrays of Strings[^]. This link will give you idea, how to use the array.

                Prasad Notifier using ATL | Operator new[],delete[][^]

                G Offline
                G Offline
                georgekjolly
                wrote on last edited by
                #7

                Hi Prasad, Thank you Very much George

                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