我想用一个函数来判断edit里面是否含有某个字符,当含有和不含有时执行不同的操作
有知道的蝈蝈指点下啊
谢谢

解决方案 »

  1.   

    CString str;
    GetDlgItem(IDC_EDIT1)->GetWindowText(str)
    if(-1 == str.Find("xxx"))
    not found
      

  2.   

    strchr或者wcschr搜索一下字符不就成了么
      

  3.   

    这个怎么返回程只有-1,写成if  else就会有一个错误啊·
      

  4.   

    CString str; 
    GetDlgItem(IDC_EDIT1)->GetWindowText(str) 
    if(-1 == str.Find("x")) 
    not found
      

  5.   

    这是我写的程序
    case 0:
    {UpdateData();

    GetDlgItem(IDC_EDIT1)->GetWindowText("m_edit1"); if(-1 == m_edit1.Find("."))
    {CString num;
    num.Format(_T("%s"),".");

    CEdit *m_Edit=(CEdit *)GetDlgItem(IDC_EDIT1);
    int nLen=m_Edit->GetWindowTextLength(); 

    m_Edit->SetSel(nLen, nLen); 
    m_Edit->ReplaceSel(num); }
    else{


    }


    }
    break;
    用了CString str; 
    GetDlgItem(IDC_EDIT1)->GetWindowText(str) 
    if(-1 == str.Find("x")) 
    not found后显示error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'char [8]' to 'class CString &'
            A reference that is not to 'const' cannot be bound to a non-lvalue
    Error executing cl.exe.的错误,这个应该是指返回值只有-1这一个吧,没有非-1的返回值也就不能用if  else啦
    大家帮我看下啊·