LSET

LSET stringvar = string

Left aligns a string within a string variable.


stringvarName of the string (String).
stringString expression to be right aligned within the stringvar (String).

REMARKS
* This statement can also be used to copy a variable of one user defined type to another variable of a different user-defined type.
* Left aligns a string within a string variable or copies a variable from one type to another type.
* This statement replaces any left over characters in "stringvar" with spaces.
* If "string" is longer than "stringvar" then only the left most characters up to the length of the "stringvar" are included.
* You can use the RSET statement to right align a string within a string variable.
* The equivalent .NET function is Microsoft.VisualBasic.Strings.LSet
* For the Microsoft documentation refer to learn.microsoft.com

Dim MyString1 As String 
MyString1 = "0123456789" ' Initialize string 10 characters.
Debug.Print VBA.Len(MyString1) ' 10

LSet MyString1 = "shorter" ' MyString contains "shorter ".
Debug.Print "'" & MyString1 & "'"

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top