• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

Converting string to double

How does one convert a string from a text box and convert it to a double value or integer? Need to get a double number from a text box and assign it to a double argument.

double myVal;

txtBoxName->Text->ToDouble( myVal );

1 Solution
You can use the Double (Int32) Parse methods or the System.Convert class.
Try either atof(const char*) or atoi(const char*).

So, you will get something like this:

extern CEdit textBox;
CString strText;
double dVal = 0;
textBox->GetLine(0, strText);
dVal = atof(strText);

Assuming the textBox is a CEdit ctrl declared somewhere in your code.

Hope this helps,

Mr_CrabsAuthor Commented:
double myVal;

myVal = Convert::ToDouble( txtBoxNumber->Text );

Oh, i did not understand all of that so I looked it up at msdn.
It is also alot easier that what mactep13 suggested, whatever that was.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now