求怎样把hexdata1-10数组重新放在一个数组中,然后进行求校验码的程序,具体如下,谢谢赐教!!
void CMyDlg::OnButtonShuaxin()
{
// TODO: Add your control notification handler code here
CString str,str1,str2,str3,str4,str5,temp,temp1,temp2,temp3,temp4,temp5;
CByteArray hexdata,hexdata1,hexdata2,hexdata3,hexdata4,hexdata5,hexdata6,hexdata7,hexdata8,hexdata9,hexdata10,hexdata11;
hexdata1.Add(0xAA);
hexdata1.Add(0x00);
hexdata1.Add(0x2C);
hexdata1.Add(0x01);
hexdata1.Add(0x01);
hexdata1.Add(0x00);
hexdata1.Add(0x27);
hexdata1.Add(0x00);
m_cComm.SetOutBufferCount(0);
m_cComm.SetOutput(COleVariant(hexdata1));
m_xinhao.GetWindowText(str1);
int n1=atoi(str1);
temp1=algorismtohex(n1);
int len1=String2Hex(temp1,hexdata2);
m_cComm.SetOutput(COleVariant(hexdata2));
m_gonglv.GetWindowText(str2);
int n2=atoi(str2);
temp2=algorismtohex(n2);
int len2=String2Hex(temp2,hexdata3);
m_cComm.SetOutput(COleVariant(hexdata3));
hexdata4.Add(0x00);
m_cComm.SetOutBufferCount(0);
m_cComm.SetOutput(COleVariant(hexdata4));
m_maikuan.GetWindowText(str3);
int n3=atoi(str3);
n3=n3*2;
temp3=algorismtohex(n3);
int len3=String2Hex(temp3,hexdata5);
m_cComm.SetOutput(COleVariant(hexdata5));
hexdata6.Add(0x00);
hexdata6.Add(0x00);
m_cComm.SetOutBufferCount(0);
m_cComm.SetOutput(COleVariant(hexdata6));
m_pinlv.GetWindowText(str4);
int n4=atoi(str4);
temp4=algorismtohex(n4);
int len4=String2Hex(temp4,hexdata7);
m_cComm.SetOutput(COleVariant(hexdata7));
hexdata8.Add(0x00);
hexdata8.Add(0x01);
hexdata8.Add(0x00);
hexdata8.Add(0x01);
hexdata8.Add(0x00);
hexdata8.Add(0x00);
hexdata8.Add(0x00);
hexdata8.Add(0x01);
hexdata8.Add(0x08);
hexdata8.Add(0x08);
hexdata8.Add(0x00);
hexdata8.Add(0x00);
m_cComm.SetOutBufferCount(0);
m_cComm.SetOutput(COleVariant(hexdata8));
m_zhouqi.GetWindowText(str5);
int n5=atoi(str5);
temp5=algorismtohex(n5);
int len5=String2Hex(temp5,hexdata9);
m_cComm.SetOutput(COleVariant(hexdata9));
hexdata10.Add(0x08);
hexdata10.Add(0x00);
hexdata10.Add(0x03);
hexdata10.Add(0x00);
hexdata10.Add(0x03);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x01);
hexdata10.Add(0x00);
hexdata10.Add(0x01);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
hexdata10.Add(0x00);
m_cComm.SetOutBufferCount(0);
m_cComm.SetOutput(COleVariant(hexdata10));
}
------解决方案--------------------
用 Append()啊