Here is my problem. My code consist of two edit boxes: IDC_BOX_1 and IDC_BOX_2. and one button to Execute. The idea is for someone to enter a number in the first edit box, IDC_BOX_1, and after pushing the Execution button, the number in IDC_BOX_1, gets multiplied by two and displayed in the second edit box, IDC_BOX_2. Here is the code I am using. I am using Visual C++ developer studio.
TWO EDIT BOXES and two CString variables:
1.IDC_Box_1 CString m_box_1
2.IDC_Box_2 CString m_display
ONE EXECUTION BOX:
1. IDC_Execute
Here is the code I am using to program the EXECUTION BOX.
void CMyDlg::OnExecute()
{
int z;
CString m_box_1;
CString m_display;
z = atoi(m_box_1);
m_display.Format("%d",z * 2);
UpdateData(FALSE);
}
When I try to use the program, it compiles, but when I input for example: a 3 the output that is displayed is 0, instead of 6. I tried to no avail. So I attempted to code the EXECUTION button differently. This is the second code I tried.
void cmyDlg::onExecute()
{
CEdit * pmnrest = (CEdit*)GetDlgItem(IDC_BOX_1);
CEdit * pmndisplay = (CEdit*)GetDlgItem(IDC_BOX_2);
CString z;
CString y;
CString m_box_1;
y = atoi(m_box_1);
z=atoi(y) * 2;
pmnrest->GetWindowText(z);
pmndisplay->SetWindowText(z);
}
When I input this code, it compiles, but when I input 5 into IDC_BOX_1, and push the Execute button, 5 is also displayed in the IDC_BOX_2, instead of 10. Please help me if you can.