0

I can't figure out how to convert my int value back to a string for use in a textbox. I already pulled it out converted it to int, did the equation now I just want to flip it back to display in a textbox.

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

                int cost = Convert::ToInt32(costbuy->Text);
                int amount = Convert::ToInt32(amountb->Text);
                int costnow = Convert::ToInt32(nowcost->Text);
                int frontcost = cost*amount;
                int endcost = costnow*amount;
                int makebreak = endcost-frontcost;
                string makebreak1 = makebreak.ToString();
                ;
                end->Text = makebreak;

             }

It's a stock value calculator if that helps make sense of the code.

3
Contributors
3
Replies
7
Views
4 Years
Discussion Span
Last Post by valestrom
Featured Replies
  • It is probably a simply typo. The string conversion produces a .NET string of type `System::String^`, not a C++ string of type `std::string`. If you use the lower-case name `string`, my guess is that it refers to `std::string`, which is not the same as `System::String^`. This should work: System::String^ makebreak1 … Read More

1

It is probably a simply typo. The string conversion produces a .NET string of type System::String^, not a C++ string of type std::string. If you use the lower-case name string, my guess is that it refers to std::string, which is not the same as System::String^. This should work:

System::String^ makebreak1 = makebreak.ToString();

If you want a C++ string, then you will have to marshal the .NET String.

0

It is probably a simply typo. The string conversion produces a .NET string of type System::String^, not a C++ string of type std::string. If you use the lower-case name string, my guess is that it refers to std::string, which is not the same as System::String^. This should work:

System::String^ makebreak1 = makebreak.ToString();

If you want a C++ string, then you will have to marshal the .NET String.

Absolutely beautiful. Thanks mike, and everyone else who contributed as well! Helping me understand more and more.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.