RDC11044: LSet of a record that holds a variable-length String
Severity: Warning · Family: RDC (Rubberduck Core analyzers) ·
Raised by: LSetOfARecordWithAStringAnalyzer
LSet copies one record (a variable of a user-defined type) into another, and either record holds a variable-length String field.
MS-VBAL §5.4.3.6
allows LSet between any two records, and RD-VBA runs it. Microsoft Office VBA refuses it: "Compile error: Type mismatch" (observed in Excel). This warning marks code
that does not compile in Microsoft Office VBA.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A record is copied into a record of the same type. | LSet copy = entry, with both of a type that has a Name As String field |
Assign it: copy = entry. |
| A record is copied into a record of another type. | LSet header = entry, with entry of a type that has a Name As String field |
Copy the fields one by one: header.Code = entry.Code. |
| The string field can have a fixed length. | Name As String in a record copied with LSet |
Declare it with a length: Name As String * 32. |
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca