读书人

获取编辑框十进制数转换为十六进制数

发布时间: 2012-04-19 14:36:43 作者: rapoo

获取编辑框十进制数,转换为十六进制数发送出去???求大侠改改下面程序!!!
void CMyDlg::OnButtonShuaxin()
{
// TODO: Add your control notification handler code here
CString str;//声明字符串变量
CByteArray hexdata;//发送的数据
hexdata.Add(0xAA);
hexdata.Add(0x00);
m_cComm.SetOutBufferCount(0);//清空发送缓冲区
m_cComm.SetOutput(COleVariant(hexdata));//发送十六进制数据
int n;
switch(n)
{
case 10:
str="A";
break;
case 11:
str="B";
break;
case 12:
str="C";
break;
case 13:
str="D";
break;
case 14:
str="E";
break;
case 15:
str="F";
break;
default:
str.Format("%d",n);
}
m_xinhao.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据
m_gonglv.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据
m_maikuan.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据
m_zhouqi.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据
m_pinlv.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据
m_bujin.GetWindowText(str);//获取编辑框内容
m_cComm.SetOutput(COleVariant(str));//发送十六进制数据

}

[解决办法]
str.format("%x",string);

读书人网 >C++

热点推荐