怎样用combo box作出一个小型计算器

热血打工人 2017-12-25 11:44:41
void CMyDlg::OnButton()
{
// TODO: Add your control notification handler code here
CString str1;
GetDlgItemText(IDC_EDIT1,str1);
CString str2;
GetDlgItemText(IDC_EDIT2,str2);
int iPos=((CComboBox*)GetDlgItem(IDC_COMBO))->GetCurSel();
int i;


switch(iPos)
{
case 1:
i=atoi(str1) + atoi(str2);
break;
case 2:
i=atoi(str1) - atoi(str2);
break;
case 3:
i=atoi(str1) * atoi(str2);
break;
case 4:
i=atoi(str1) / atoi(str2);
break;

}

SetDlgItemText(IDC_EDIT3,(CString)i);
}
...全文
167 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
热血打工人 2017-12-25
  • 打赏
  • 举报
回复
引用 2 楼 paschen 的回复:
不能这样((CString)i)把整数转换成CString,你要用CString的Format进行转换
感谢分享,已经解决。
paschen 2017-12-25
  • 打赏
  • 举报
回复
不能这样((CString)i)把整数转换成CString,你要用CString的Format进行转换
倚栏|听风 2017-12-25
  • 打赏
  • 举报
回复
所有 ,有什么问题,说明白哈

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧