Solved

COM Array (CComSafeArray::MultiDimGetAt)

Posted on 2006-06-29
7
714 Views
Last Modified: 2008-01-09
I have a COM array of doubles of type CComSafeArray, say with 10 rows and 30 columns. I simply need to retrieve its elements one by one and print them out on the screen. How do I do this with MultiDimGetAt? I have read the Microsoft documentation available on the MSDN website but it's not very clear to me, and I don't know much about COM.
Thanks.
0
Comment
Question by:Rothbard
  • 5
  • 2
7 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008437

for(int i=0; i < 10; i++)
{
    Array->GetAt(i, &Data);
    cout << Data;
}
0
 

Author Comment

by:Rothbard
ID: 17008472
What is Data in your code? Also, since our Array has two dimensions wouldn't you need MultiDimGetAt rather than GetAt?
0
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 500 total points
ID: 17008479
sorry ignore the above: do

LONG Index[2];

for(int i=0; i< 10; i++)
   for(int j=0; j < 3; j++)
{
      Index[0] = i;
      Index[1] = j;
     
      Array->MultiDimGetAt(Index, Data);
      cout << Data << endl;
}
     

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008485
Data is declared the same as the elements in your array.
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008489
In your case declare Data as double
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17008495
change for(int j=0; j < 3; j++) to for(int j=0; j < 30; j++)
0
 

Author Comment

by:Rothbard
ID: 17008514
Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question