Can someone help me translate this from VB to C++?
VB Code:
' Visual Basic version Public Function LineTrim(Expression As String) As String 'Remove trailing CRs and LFs Dim sReturn As String Dim sCheck As String sReturn = Expression sCheck = Right(sReturn, 1) Do While (sCheck = Chr(10)) Or (sCheck = Chr(13)) sReturn = Left(sReturn, Len(sReturn) - 1) sCheck = Right(sReturn, 1) Loop LineTrim = sReturn End Function
and now the C++ version, which will be in a DLL for VB
Code:LPCSTR LineTrim(LPCSTR *Expression) { // I dont want to alter the original string, // so I need to declare this return value correct? LPCSTR ReturnVal; // How can I move the pointer to the end of the LPCSTR // without looping through it until '/0' // How can I check for the ascii value of the current char, // and shorten the string if it's CR or LF? LineTrim = ReturnVal; }




Reply With Quote