cancel
Showing results for 
Search instead for 
Did you mean: 

C++ and strings mystery

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

AlexGrebennikov
Active Contributor
0 Kudos

Hi!

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>;

-


Former Member
0 Kudos

Thanx for the answer, but we have already tried it, and it did not work in this instance. In fact, having Value instead of string made our Quantity-string have the same error as we get with the Price.

Do you have any other suggestions?

AlexGrebennikov
Active Contributor
0 Kudos

HI!

Are you sure that it is exactly price-column?

It's value prefix (<b>&#</b>1031..) looks like letter-code (as in XML or HTML).. (but maybe it's the result of forumengine encoder..)

To check it just try to get value once again from previous column like this:

---

PriceText = MatrixObject->Columns->Item("<b>11</b>")->Cells->Item(Rows)->Specific;

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

---

What will be the Price value?

Former Member
0 Kudos

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());

Answers (0)