


LSet
Purpose
Left aligns a string within the space of a string variable or copies a
variable of one user-defined type to another variable of a different user-defined type.
Arguments
SYNTAX 1
LSet stringvar = stringexpr
SYNTAX 2
LSet variable1 = variable2
The LSet statement uses these arguments:
stringvar Name of a String variable.
stringexpr String expression to be left aligned within stringvar.
variable1 Name of the user-defined type variable being copied to.
variable2 Name of the user-defined type variable being copied from.
Notes
If stringexpr is shorter than stringvar, LSet left aligns stringexpr within stringvar. LSet replaces any leftover characters in stringvar with spaces. If stringexpr is longer than stringvar, LSet places only the leftmost characters, up to the length of stringvar, in stringvar. Characters beyond the length of stringvar are truncated from the right. Use LSet with Syntax 2 to assign one user-defined type variable to another.
Example
The following example copies the contents of RecTwo (a user-defined type
variable) to RecOne (a variable of another user-defined type):
Type TwoString
StrFld As String * 2
End Type
Type ThreeString
StrFld As String * 3
End Type
Dim RecOne As TwoString, RecTwo As ThreeString
LSet RecOne = RecTwo
Because RecOne is 2 bytes long, only 2 bytes are copied from RecTwo. LSet
copies only the number of bytes in the shorter of the two user-defined type
variables.
You cannot use
LSet to copy variables of different user-defined types if either contains a
variable-length string or a Variant.