Visual C++ 2010 -> Window Form. How to convert string to int?

MegaFill picture MegaFill · Jan 15, 2011 · Viewed 41.2k times · Source

Hey! I have textBox with text like "12:30" and this code textBox -> Text -> ToString() -> Split(':')[1] It return "30" as string. And I want convert it to Int. How? I founded function like Convert::ToInt32() etc, but it doesnt work for my c++ (Visual C++ 2010 -> Winfow Form). Help me plz! (I started learn c++ 2 days ago)

And i use Managed C++

Answer

Nawaz picture Nawaz · Jan 15, 2011

As you're using Managed C++, then you can do this:

double foo = System::Convert::ToDouble("200");
int bar = System::Convert::ToInt32("200");

Use whatever you need!