search

Home  >  Q&A  >  body text

c++ - 基于MFC对话框的简单操作(学生党初入门)

我想就是只要在“示例编辑框”中打上的字中有“姓名”(或者是身高体重)两个字,然后点击“查询”下面的编辑框中就会出现某个人的名字(或者身高体重),如果输入其他的我没有编写的进程序的问题点击查询就会出现“无法识别”的字样,所以button3里面的程序应该怎么写呢,求助大神!

巴扎黑巴扎黑2803 days ago569

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:30:40

    I don’t know if my understanding is correct:
    If you enter the name: Laowang, click the query to display Laowang
    If you enter the increase: 170, click the query to display 170
    If you If xxx is entered, the unrecognized string
    will be displayed. If so, the code is as follows for reference only:

    CString    strInput,strOutput;  //第一个字符串表示输入,后面一个表示下面的输出
    int        nPOS = 0;
    
    strOutput.Format(_T("无法识别字符串"));
    nPOS = strInput.find(_T("姓名:"));   //也可以是 "姓名"不过要注意后面删除的时候要多加一位
    if (nPOS != -1) {
        strOutput = strInput;
        strOutput.delete(0,nPos+1);
    } else {
        nPOS = strInput.find(_T("身高:"));
        if (nPOS != -1) { 
            strOutput = strInput;
            strOutput.delete(0,nPos+1);
        }
    }
    //更新显示
    
    
    return;

    In fact, this operation mainly involves the processing of strings. If it is a String, it can also be processed using regular matching in C++11.

    reply
    0
  • Cancelreply