Главная страница | назад





Article #17465: Where are the equivalent functions for the Visual Basic Trim functions?

 Question and Answer Database

FAQ2465C.txt   Where are the equivalent functions for the Visual Basic Trim functions?
Category   :VCL
Platform    :All
Product    :C++Builder  3.x

Question:
Where are the equivalent functions for the Visual Basic Trim
functions?

Answer:
There are many ways to implement these and similar functions. The
following example is a great start for a string handling unit to add 
to your programming tool box.

#include 
#define MAX 32
void __fastcall TForm1::LTrim(AnsiString s)
{
    while((s.Length() > 0) && (s[1] == MAX))
    {
        s.Delete(1,1);
    }
}

void __fastcall TForm1::RTrim(AnsiString s)
{
    while((s.Length() > 0) && (s[s.Length()] == MAX))
    {
        s.Delete(s.Length(), 1);
    }
}

void __fastcall TForm1::Trim(AnsiString s)
{
    LTrim(s);
    RTrim(s);
}



7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99