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
views:
171answers:
3
A:
Assuming that you have the variable in a std::string
instance, you can use streams to do it like this:
std::string str = "1";
std::istringstream iss;
iss.str(str);
int val = 0;
iss>>val;
Naveen
2010-03-25 17:07:29
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
2010-03-25 17:24:24
A:
As long as you can access the raw character data in the text box you can simply use atoi
fbrereto
2010-03-25 17:07:34
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
2010-03-25 17:24:54
+2
A:
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.
OregonGhost
2010-03-25 17:18:48
`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++.
OregonGhost
2010-03-29 08:26:10