我想制作一个计算器通过控件来接收用户输入用户输入过来的是字符串类型我想让其转换为int类型 进行运算 但困惑好久不知怎么下手void CMFCDlg::OnBnClickedButton1()
{
CString str1, str2; GetDlgItemText(IDC_EDIT1, str1); // 第一个控件。
GetDlgItemText(IDC_EDIT2, str2); // 第二个控件。 CString result;
result = str1 + str2; MessageBox(result,NULL,MB_OK);
}
{
CString str1, str2; GetDlgItemText(IDC_EDIT1, str1); // 第一个控件。
GetDlgItemText(IDC_EDIT2, str2); // 第二个控件。 CString result;
result = str1 + str2; MessageBox(result,NULL,MB_OK);
}
解决方案 »
- 我开发的LSPlayer播放器V1.5
- IDocHostShowUI该怎么使用?
- 简单的问题:include "" 和 include <>的区别?
- 对话框可不可以多重继承。
- !!!哪位高手有空呢!!!帮帮忙看段多线程socket代码!!!
- 哪里有Com Essential 《Com本质论》下载
- VC 程序运行期间错误提示
- 硬盘出了点问题,白白少了好几G,谁能帮帮我呀。。。!
- what is the problem!!!!!!!
- 我在自己的机子做了一个程序,要拷几个文件到别人的机器上才可运行?
- 单片机与PC机通过RS232通信,发送数据1接收到的却是EF,
- VC开发的ISAPI 扩展程序是否可以删除磁盘上的文件?
用int型和edit关联起来更方便吧
CString str1,str2,str3;
GetDlgItem(IDC_EDIT1)->GetWindowText(str1);
GetDlgItem(IDC_EDIT2)->GetWindowText(str2);
num1 = _wtoi(str1);
num2 = _wtoi(str2);
num3 = num1 + num2;
str3.Format(L"%d", num3);
GetDlgItem(IDC_EDIT3)->SetWindowText(str3);
这段代码 误打误撞的找到了 我仔细分析下 已经自解.