Description
Left aligns a string within a string variable, or copies a variable of one user-defined type to another variable of a different user-defined type.
Syntax
LSet stringvar = string
LSet varname1 = varname2
The LSet statement syntax has these parts:
Part |
Description |
stringvar |
Name of string variable. |
string |
String expression to be left aligned within stringvar. |
varname1 |
Variable name of the user-defined type being copied to. |
varname2 |
Variable name of the user-defined type being copied from. |
Remarks
LSet replaces any leftover characters in stringvar with spaces.
If string is longer than stringvar, LSet places only the leftmost characters, up to the length of the stringvar, in stringvar.
Only user-defined types containing Integer, Long, Double, Single, String (fixed-length), or Currency types may be copied. 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.
See Also
RSet Statement.
Example
This example uses the LSet statement to left align a string within a string variable and to copy a variable of one user-defined type to another variable of a different user-defined type.
MyString = "0123456789" ' Initialize string. LSet MyString = "<-Left" ' MyString contains "<-Left ". ' LSet is also used to copy a variable of one user-defined type to ' another variable of a different user-defined type. ' Module level. Type AType ' Define types. AName As String * 10 AAdd As String * 10 End Type Type BType BName As String * 5 BAdd As String * 5 End Type ' Procedure level. Dim AVar As AType, BVar As BType ' Declare variables. AVar.AName = "John Smith" ' Define fields. AVar.AAdd = "Rodeo Drv." LSet BVar = AVar ' Copy variables. ' After copying, values are truncated. Debug.Print BVar.BName ' Prints "John ". Debug.Print BVar.BAdd ' Prints "Smith".