About MS VC++ 6

Can any experts tell me how to use MS VC++ 6 edition to
create a simple 'ADD' program.

For example, it should have three textboxes and one button.
Two textboxes are for inputs and ine textbox is for output
of the addition from these two textboxes.

Can you show me step by step ?
LVL 1
tanc02Asked:
Who is Participating?
 
GlennDeanConnect With a Mentor Commented:
tanc02:
   Here's some steps:
1.  Create a project using the MFC App Wizard and choose a Dialog-based app
2.  Open up the resource editor and open up the dialog resource.  Then, add 4 controls from the control tool (3 edit boxes and one button).
3.  In ClassWizard, add data members for the 3 edit boxes.  Make sure you don't accept ClassWizard's default of CString for the member type (choose double).  What creating a data member accomplishes is when the user changes the data on the screen the framework will change the data member to reflect the changes.  Call the 3 members m_dLeft, m_dRight, m_dAnswer.
4.  Also in ClassWizard, on the Message Map tab, click on the button resource id (the default should be IDC_BUTTON1) and then add a handler for BN_CLICKED.
5.  Edit the code for the BN_CLICKED handler.  Should look something like:
   UpdateData(TRUE); //Get data from screen
   m_dAnswer=m_dLeft+m_dRight;
   UpdateData(FALSE); //Store data onto screen

   Good luck,
           Glenn
0
 
tanc02Author Commented:
when I compiled, it told me that my three variables were undeclared
0
 
GlennDeanCommented:
tanc02:
   The problem you're probably having is that when you add the member variables via ClassWizard, make sure you're on the Member Variables tab, and make sure the Class Name is the name of the Dialog containing the 3 edit boxes you've added to the dialog.
   Also note that you have to add the edit boxes to the dialog first before you add the member variables (the default ID's for the boxes should be IDC_EDIT1,IDC_EDIT2,IDC_EDIT3).  Then, on the member variables tab, highlight the id and then click Add Variable.
   Glenn
0
All Courses

From novice to tech pro — start learning today.