1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! VB6 LSet statement syntax:
//! - LSet stringvar = string
//! - LSet varname1 = varname2 (for user-defined types)
//!
//! 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.
//!
//! The LSet statement syntax has these parts:
//!
//! | Part | Description |
//! |---------------|-------------|
//! | stringvar | Required. Name of string variable. |
//! | string | Required. String expression to be left-aligned within stringvar. |
//! | varname1 | Required. Variable name of the user-defined type being copied to. |
//! | varname2 | Required. Variable name of the user-defined type being copied from. |
//!
//! ## Remarks
//!
//! - LSet left-aligns strings within string variables.
//! - If string is shorter than stringvar, LSet left-aligns the string in stringvar and pads
//! remaining characters with spaces.
//! - If string is longer than stringvar, LSet places only the leftmost characters that fit into
//! stringvar.
//! - Warning: Using LSet to copy variables of different user-defined types is not recommended.
//! Copying variables of one user-defined type into variables of a different user-defined type
//! can produce unpredictable results.
//! - When copying between variables of user-defined types, the memory assigned to one variable is
//! copied byte-for-byte to the memory assigned to the other variable.
//! - LSet is commonly used with fixed-length strings.
//! - LSet can be used with variant variables that contain strings.
//!
//! ## Examples
//!
//! ```vb
//! LSet MyString = "Left"
//! LSet FixedString = userName
//! LSet myRecord = sourceRecord
//! ```
//!
//! ## Reference
//!
//! [LSet Statement - Microsoft Docs](https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/lset-statement)
use VBResult;
use crateVBString;
/// Left-aligns `string` within `stringvar`, returning the aligned result.
///
/// If `string` is shorter than `stringvar`, the remainder is padded with
/// spaces on the right; if it is longer, only the leftmost characters that
/// fit are kept. The width used is the current length of `stringvar`, which
/// mirrors a fixed-length string's declared size when callers track it.
///
/// # Errors
///
/// Never fails for string operands; returns `VBResult` for consistency with
/// the statement surface (user-defined-type copies may fail in the future).