菜鸟终于决定从delphi改学vc++了,请教一个问题:我在窗体上放了一个edit和一个button,我想点击按钮当edit里的内容等于‘测试’时就弹出提示:‘内容对了’,否则就弹出‘内容错了’。谁帮帮菜鸟啊!!菜鸟是这么做的:
我先给edit加了一个成员变量:m_edit1
然后写代码:
if m_edit1=="测试" AFXmessagebox("内容对了"); 怎么不好使啊?

解决方案 »

  1.   

    UpdateData(TRUE);
    if m_edit1=="测试" AFXmessagebox("内容对了");
      

  2.   

    大侠,出现错误:
    --------------------Configuration: 2 - Win32 Debug--------------------
    Compiling...
    2Dlg.cpp
    F:\VC练习\2\2Dlg.cpp(178) : error C2061: syntax error : identifier 'm_edit1'
    Error executing cl.exe.2.exe - 1 error(s), 0 warning(s)
      

  3.   

    检查你的m_edit1是不是CString类型的.还有可能是赋值错误,if(m_edit1 ==_T("测试"))
    AfxMessageBox("内容对了");
      

  4.   

    楼上说的方法是给Edit关联一个变量m_edit1(在Class Wizard中添加)方法二:在button对应的函数中
     CString str;
            GetDlgItemText(IDC_EDIT, str); 
            if(strcmp(str, "测试")==0)
                 AfxMessageBox("内容对了");
            else
                 AfxMessageBox("内容错了");
      

  5.   

    还是给Edit关联一个变量m_edit1操作起来比较方便。