RDC11019 — Type character ignored on a function of the library
Severity: Warning · Family: RDC (Rubberduck Core analyzers) ·
Raised by: IgnoredTypeCharacterAnalyzer
A built-in function such as Len, CVar or Abs is written with a type character that does not match the type it returns: Len$("abc"), CVar$(5),
Abs%(-3).
The language specification says a name written with a type character that does not match its declared type is invalid. MS-VBA compiles these anyway, and
ignores the character: Len$("abc") is 3, a Long, not a String, and CVar$(5) is 5, an Integer (recorded in Excel, as vb6.exe does). RD-VBA does as
MS-VBA does, and warns: the character says a type the call does not have.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A reserved function of the library (Len, LenB, CVar, Abs, Fix, Int, Sgn, CInt, CLng, CDbl, CBool and the other conversion functions) written with a type character that is not its type. |
n = Len$(s) |
Remove the character: n = Len(s). |
Notes
A character that matches the function's type (CStr$(1), a String) is what the function returns, and is not reported.
Any other function of the library refuses a character that does not match, in MS-VBA as in RD-VBA: Asc$("A") and Sqr$(4) are
VBC09335 Type-declaration character does not match declared data type. A function that has a $ form of its own (Left$, Mid$) is that
function, and returns a String.
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca