String Methods - PadRight & PadLeft

 

The PadRight and PadLeft string methods provided a tool to align data in columns

 

The Padright string method left-aligns the characters in the length indicated padding on the right with spaces

 

Assuming

strFname = "Joe", strLname = "Smith", strTitle = "President"

The statement

strOutput &= strFname.PadRight(12) & strLname.PadRight(12) & strTitle  & ControlChars.Newline

 

Will store the following string in the strOutput variable

 Joe         Smith       President

 

If the statement is executed again with the values

strFname = "Sarah", strLname = "Johnson", strTitle = "Vice-President"

The string variable strOutput will contain

Joe         Smith       President
Sarah       Johnson     Vice-President   

 

 

The Padleft string method right-aligns the characters in the length indicated padding on the left with spaces