string to integer type conversion if the string is taken from text box in visual c++ using visual studion n windows forms

14,157

Solution 1

i am using visual c++ windows forms and the visual studio

If it's really Windows Forms (i.e. C++/CLI) it's just Int32::Parse or Int32::TryParse, just like in any other .NET language.

Solution 2

I think what he wanted was:

String^ numberS = "42";
int number;

number = Convert::ToInt32(numberS);
Share:
14,157
suman
Author by

suman

Updated on June 28, 2022

Comments

  • suman
    suman almost 2 years

    i need the code to convert the string type data into integer type data if i have entered a numerical value in the text box. i am using visual c++ windows forms and the visual studio

  • suman
    suman about 14 years
    System::String^ txt1 = this->textBox1->Text; System::String^ s = txt1; txt1 = ""; this->textBox1->Text = txt1; my code is as above....i have to convert this string s to integer type
  • suman
    suman about 14 years
    System::String^ txt1 = this->textBox1->Text; System::String^ s = txt1; txt1 = ""; this->textBox1->Text = txt1; my code is as above....i have to convert this string s to integer type
  • OregonGhost
    OregonGhost about 14 years
    int i = Int32::Parse(myTextBox->Text); If it still doesn't work, post what you already have and describe exactly what doesn't work. I don't really know C++/CLI, however, let alone Managed C++.