要求VC串口每接收一次数据,显示在不同的编辑框中,但结果都显示在一个中,请教如何解决?flag应该放在哪? 10
staticunsignedintflag;flag=0;CStringm_edit;m_edit.Format(("%d"),myData);intdata=atoi(...
static unsigned int flag;
flag=0;
CString m_edit;
m_edit.Format(("%d"),myData);
int data=atoi(m_edit);
if(flag==0&&data!=11)
{
m_edit1.Format(("%d"),myData);
switch(data)
{
case1:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case2:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case3:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case4:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case5:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case6:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case7:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case8:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case9:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case10:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
}
}
elseif(data==11)
{
flag=1;
}
if(flag==1&&data!=11)
{
m_edit2.Format(("%d"),myData);
switch(data)
{
case1:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case2:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case3:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case4:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case5:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case6:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case7:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case8:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case9:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
}
}
elseif(data==11)
{
flag=2;
} 展开
flag=0;
CString m_edit;
m_edit.Format(("%d"),myData);
int data=atoi(m_edit);
if(flag==0&&data!=11)
{
m_edit1.Format(("%d"),myData);
switch(data)
{
case1:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case2:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case3:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case4:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case5:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case6:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case7:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case8:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case9:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
case10:
{
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
break;
}
}
}
elseif(data==11)
{
flag=1;
}
if(flag==1&&data!=11)
{
m_edit2.Format(("%d"),myData);
switch(data)
{
case1:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case2:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case3:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case4:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case5:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case6:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case7:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case8:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
case9:
{
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
break;
}
}
}
elseif(data==11)
{
flag=2;
} 展开
2个回答
展开全部
把你的代码直接改成如下看看……
static unsigned int flag;
flag=0;
CString m_edit;
m_edit.Format(("%d"),myData);
int data=atoi(m_edit);
if(flag==0 && data!=11){
m_edit1.Format(("%d"),myData);
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
}
else if(data==11) flag=1;
if(flag==1 && data!=11){
m_edit2.Format(("%d"),myData);
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
}
else if(data==11) flag=2;
static unsigned int flag;
flag=0;
CString m_edit;
m_edit.Format(("%d"),myData);
int data=atoi(m_edit);
if(flag==0 && data!=11){
m_edit1.Format(("%d"),myData);
GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
}
else if(data==11) flag=1;
if(flag==1 && data!=11){
m_edit2.Format(("%d"),myData);
GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
}
else if(data==11) flag=2;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询