Skip to Content
0
Former Member
May 26, 2005 at 02:14 PM

C++ and strings mystery

19 Views

We have a problem with getting correct values from the MatrixObject.

The BSTR objects returned from the String property of the EditText-object didn't work so well, the BSTR object were continually changing, and some seemed to have the same memory addresses.

We therefore try to change the BSTR strings to wstrings in the following code example:

ItemCodeText = MatrixObject->Columns->Item("1")->Cells->Item(Rows)->Specific;

std::wstring ItemCode = (std::wstring)ItemCodeText->String;

DescriptionText = MatrixObject->Columns->Item("3")->Cells->Item(Rows)->Specific;

Descr = (std::wstring)DescriptionText->String;

QuantityText = MatrixObject->Columns->Item("11")->Cells->Item(Rows)->Specific;

Quantity = (std::wstring)QuantityText->String;

PriceText = MatrixObject->Columns->Item("21")->Cells->Item(Rows)->Specific;

Price = (std::wstring)PriceText->String;

In the debugger, ItemCode, Descr and Quantity gives the correct strings, but Price did not work.

It just gives us this:

Price {"⡈ê"}

Can anybody help us?