Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert string to number?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hello,

Im just starting to learn vc++ , Have a simple question you pros surley can answer easilty.

For example. I have 3 editboxes on my form.

How can Edit3->Text=Edit2->Text*Edit1->Text


I know I should convert the string to a number first , but dont know how to
do that?

In C++Builder it would be like this:
Edit3->Text=IntToStr(StrToInt(Edit2->Text)*StrToInt(Edit1->Text));

Can someone please give some sample code on how to do this in VisualC++.

Thanks.



 
you want to have member variables associated with the edit boxes

CString m_edit1;
CString m_edit2;
CString m_edit3;

you then want to call update data with TRUE as a parameter to pull the data in from the edit boxes;

int value1 = atoi((LPCTSTR)m_edit1);

etc...

Matt
 
you can use this (sometimes it works)
it's called "cast"

int iNumberX = (int*)m_editX;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top