CString str1,str, str2; GetDlgItemText(IDC_EDIT1, str1); GetDlgItemText(IDC_EDIT2, str2); UINT value3 = _ttoi(str2); if ( 0 == value3) { return; } double value1 = _ttof(str1); double value2 = _ttof(str2); double value = value1 / value2; str.Format(_T("%.3f"), value); GetDlgItem(IDC_STATIC_VALUE)->SetWindowText(str);
在mfc中使用寬字節的轉換函數_ttoi()轉為整型,_ttof()轉為浮點型,使用cstring.format()把整型和浮點型轉為字符串