PadLeft method

Official Content
This documentation is valid for:

Builds a character expression from another one, by adding a specified character N times, or blanks to the left.


Str.PadLeft(Len [,FillChar])


   Is the character expression from which you want to add left blanks or with the FillChar if indicated

   Is the numeric expression that indicates the length of the returned string.

   Is the character that is added to the left side of ‘Str’. It is an optional parameter, if it is not specified then blanks will be added.

Type Returned:


Data Types: CharacterVarCharLongVarChar
Generators: .NET, .NET Framework, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)


Returns a character string, which is the result of adding the ‘FillChar’ to the left side of ‘Str’ as many times until the string is left as long as 'len'.


&MyText = “My string”
&Result=&MyText.PadLeft(10, ‘*’) // &Result value is “*My string”
&MyText = “My string”
&Result=&MyText.PadLeft(11, ‘*’) // &Result value is “**My string”
&MyText = “My string”
&Result=&MyText.PadLeft(12, ‘*’) // &Result value is “***My string”
&MyText = “My string”
&Result=&MyText.PadLeft(12)       // &Result value is “   My string”
Note: All leading spaces from the original string will be removed before applying the function.

See Also

PadR function
PadL function
Trim function
LTrim function
RTrim function