Skip to Content
author's profile photo Former Member
Former Member

C++ and strings mystery

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?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on May 26, 2005 at 08:03 PM


    Try to use proberty EditText::Value in the following way:


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

    Price = (std::wstring)PriceText-><b>Value</b>;


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Alexey Grebennikov

      No, it got encoded by the forumengine.

      But we have now solved the problem.

      We tried converting the string from wstring to System::String, and then the correct string automagically appeared...

      System::String* Price2 = new String(Price.c_str());

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.