Use ONE dialog.
Attach a CEdit to the the control (use classwizard)- I've called it CEditCtrl here:

OnCalculate()// the button clik handler
{
CString szVal;
m_EditCtrl.GetWindowText(szVal);
// do your calc, setting result into szVal;
m_EditCtrl.SetWindowText(szVal);
}

that's all you need.