LSet Function

Returns a left-aligned string containing the specified string, adjusted to the specified length.

Public Shared Function LSet( _
    ByVal Source As String, _
    ByVal Length As Integer _
) As String


  • Source
    Required. String expression. String variable to be adjusted.

  • Length
    Required. Integer expression. Length of returned string.


If Source is longer than Length, LSet returns only the leftmost characters, up to the length of Length. If Source is shorter than Length, LSet adds spaces to the right end of the returned string to produce the appropriate length.


This example demonstrates the use of the LSet function.

Dim TestString As String = "Left" 
Dim lString As String 
' Returns "Left      "
lString = LSet(TestString, 10)
' Returns "Le"
lString = LSet(TestString, 2)
' Returns "Left"
lString = LSet(TestString, 4)




Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

See Also


Efficient Use of Data Types


String Manipulation Summary

Data Type Summary (Visual Basic)

RSet Function