比如有 
CString strValue1;
CString strValue2;CString strValue;strValue = strValue1 + strValue2;这样不行吗?我看说明是这样写的,可是strValue为空啊(strValue1 = "10"  strValue2 = "20")
我要得到1020

解决方案 »

  1.   

    我调试的时候
    在strValue = strValue1 + strValue2;这句代码里strValue1和strValue2都有值,但是运行完这一句,strValue还是为空
      

  2.   

    囧……
    CString strValue = _T("");
    赋初值试试看
      

  3.   

    帮你试了下
        CString strA = L"10";
        CString strB = L"20";
        CString strC;
        strC = strA + strB;
        MessageBox(strC);
    没有任何问题
      

  4.   

    我给了一个初值 "a";
    结果运行完那一句 strValue = strValue1 + strValue2; 
    strValue的值就变空了,把之前赋值的初值"a" 也没了
      

  5.   


    strValue = strValue + strValue1 + strValue2;
    这样呢?
      

  6.   

    这样的话就应该是 strValue1 和 strValue2出问题了吧
      

  7.   

    Using "Format" member function...
      

  8.   

    貌似没问题,你的strValue1和strValue2对吗?
      

  9.   

    对的,都有值的
    而且都取出来了,在界面上也显示出来了
    就是连接的时候始终不对。搞不清楚了我是在VS2008下建的MFC工程,不知道跟环境有没有关系的??
      

  10.   

    另外问一下
    CString X2Value = "0.25";
    double dblValue = atof(X2Value);
    下面double转化后,dblValue的值变成0.2500000000001这个结果对吗?其实我计算时只要0.25就行了当然,这个转化由于值很小并不影响我计算结果
      

  11.   

    我这里dblValue的值是0.25000000000000000
      

  12.   

    按楼主的代码试了试了试
    CString strValue1="10";
    CString strValue2="20";

    CString strValue="0";

    strValue = strValue1+strValue2;
    MessageBox(strValue,NULL,MB_OK);结果对啊 ,你是不是strValue1和strValue2的值有问题
      

  13.   

    我感觉也没有问题,你用的什么编译器?
    不行就用Format试试。
    CString strValue1;
    CString strValue2;CString strValue;strValue.Format(_T("%s%s"),strValue1,strValue2);;
      

  14.   

    我的环境是
    2003系统+ VS2008 + MFC基于对话框工程
      

  15.   

    strValue1 = "10" strValue2 = "20"变成strValue1 = ‘10’ strValue2 = ‘20’试试看