I am trying to Convert this Long String to an integer but when running the code, I get an error that tells that the inputstring is in an incorrect format.

How can I convert this string so I will get the ouput integer: 41517 ?

String^ ba = "41516.7095211088";
                int bb = Convert::ToInt32(ba);
                MessageBox::Show(Convert.ToString(bb));

Remember, you're using managed C++, so you need to use managed types.

String^ ba = "41516.7095211088";
Double bb = Convert::ToDouble( ba );
Int32 rounded = (Int32)Math::Round( bb );
MessageBox::Show( rounded.ToString() );

Yes, then I understand. I have to first convert it to a double and than round it, casting it to Int32.

It worked fine.
Thank you.

Remember, you're using managed C++, so you need to use managed types.

String^ ba = "41516.7095211088";
Double bb = Convert::ToDouble( ba );
Int32 rounded = (Int32)Math::Round( bb );
MessageBox::Show( rounded.ToString() );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.