编辑框写的是数据,比如23.1,读进来的是一个CString的串。我要对数据进行处理应该怎么弄啊?
我读进来的是23.1
我要先把数据变成023.10(控制数据的格式);
还要得出0+2+3+.+1+0的值作为校验和!
应该如何处理啊?

解决方案 »

  1.   

    数据变成CString应该如何弄呢?
      

  2.   

    CString str="23.1";
    int nDot=str.Find(".");CString strLeft=str.Left(nDot);
    str.Delete(0,nDot+1);
    CString strRight=str;
    CString temp;
    for(int i=0;i<3-strLeft.GetLength();i++)
    {
    temp+="0";
    } temp+=strLeft; strLeft=temp;
    for(i=0;i<2-strRight.GetLength();i++)
    {
    strRight+="0";
    } strLeft+=".";
    strLeft+=strRight; int Sum=0; for(i=0;i<strLeft.GetLength();i++)
    {
    Sum+=strLeft.GetAt(i);
    }
      

  3.   

    CString str;
    str.Format("%05.2d",23.1);
      

  4.   

    CString str;
    str.Format("%5.2f",23.1);
    自己在前面补0吧
      

  5.   

    CString str;
      .......
      float a = atof(str);
      

  6.   

    CString strTemp, strEdit;
    strEdit = _T("23.1");
    strTemp.Format(_T("0%s0"), strEdit);
    TCHAR chTemp;
    int nCheckSum = 0;
    for(int i=0; i<strTemp.GetLength(); i++)
    {
    chTemp = strTemp.GetAt(i);
    nCheckSum = (int)chTemp;
    }
      

  7.   

    有点错
    nCheckSum += (int)chTemp;