要求VC串口每接收一次数据,显示在不同的编辑框中,但结果都显示在一个中,请问怎么解决

要求VC串口每接收一次数据,显示在不同的编辑框中,但结果都显示在一个中,请教如何解决?
C/C++ code

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)
            {
                case 1:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 2:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 3:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 4:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 5:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 6:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 7:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 8:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 9:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                case 10:
                    {
                        GetDlgItem(IDC_EDITR1)->SetWindowText(m_edit1);
                        break;
                    }
                }
    }
    else if(data==11)
        {
            flag=1;
        }

    if(flag==1&&data!=11)
    {
        m_edit2.Format(("%d"),myData);
        switch(data)
        {
            case 1:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 2:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 3:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 4:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 5:
                {

                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 6:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 7:
                { 
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 8:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
            case 9:
                {
                    GetDlgItem(IDC_EDITR2)->SetWindowText(m_edit2);
                    break;
                }
        }
    }
    else if(data==11)
        {
            flag=2;

        }


串口接收到的数据一直在IDC_EDITR1里出现!flag没起到作用。。有4个编辑框。。求高手指点指点!!!实在搞不出了。。。

------解决方案--------------------
static unsigned int flag;
flag=0;