void Class1::SortEdit( CEdit& edt )
{
CString strEdt ;
edt.GetWindowText( strEdt ) ;
if ( _T("") == strEdt )
{
return ;
}
int iCount = edt.GetLineCount() ;
for ( int i = 0; i < iCount; ++i )
{
int iIndex = edt.LineIndex( i ) ;
int iLineLength = edt.LineLength( iIndex ) ;
if ( 0 == iLineLength )
{
continue ;
} TCHAR* pCharBuf = new TCHAR[ iLineLength + 1 ] ;
edt.GetLine( i, pCharBuf ) ;
pCharBuf[ iLineLength ] = _T('\0') ; TCHAR* pTempBuf = NULL ;
double dNum = _tcstod( pCharBuf, &pTempBuf ) ; CString strTempOld = strEdt.Mid( iIndex, iLineLength ) ;
CString strTempNew ;
strTempNew.Format( _T("%.6f" ), dNum ) ;
delete []pCharBuf ;
pCharBuf = NULL ; strTempOld.TrimLeft() ;
strTempOld.TrimRight() ; if ( _T("") == strTempOld )
{
continue ;
} if ( 0 == strTempNew.Find( strTempOld ) )
{
……
}
}
CString strNewOutEdt ;
…… edt.SetSel( 0, -1 ) ;
edt.Clear() ;
edt.ReplaceSel( strNewOutEdt ) ;
UpdateData( FALSE ) ;

}上述代码的第20行edt.GetLine( i, pCharBuf ) ;有时执行成功有时失败,请问这是什么原因。
比如:
我输入:
r      rgdfhg
100
200d   
400
600
300
df
有时没错,有时又出现问题,出现问题时调试发现各变量的值状态如下:+ strEdt {"
r   



   rgdfhg
100
200

d   
400
600
300
df
"}
i 10 iIndex 43 iLineLength 3- pCharBuf 0x0cea11c0 ""
0 ''+ strTempOld {"400"} dNum 0.00000000000000000+ strTempNew {"0.000000"}
继续执行完毕最后edt只剩下“100.00”,再运行一次甚至连“100.00”这个值都没了。然而,大部分情况下,程序运行又是成功的,请问这是什么原因呢?