Passing 3d string array from VC++ to VB
-
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
-
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
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 = 3BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
if (*ppOutputArray==NULL)
{Prasad Notifier using ATL | Operator new[],delete[][^]
-
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 = 3BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
if (*ppOutputArray==NULL)
{Prasad Notifier using ATL | Operator new[],delete[][^]
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
-
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
Hi George, I'm not VB guy. Lets wait some body to solve your query.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi George, I'm not VB guy. Lets wait some body to solve your query.
Prasad Notifier using ATL | Operator new[],delete[][^]
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
-
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
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[][^]
-
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[][^]
Hi Prasad, Thank you Very much George