RDC00201: Integer data type declaration
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: IntegerDataTypeAnalyzer
A declaration states the Integer type, with an As Integer clause or with the % type-declaration character
(MS-VBAL §3.3.5.3 Special Identifier Forms).
An Integer is a 16-bit signed type that overflows at 32,767, where a Long holds more than two billion
(MS-VBAL §2.1 Data Values and Value Types; RD-VBAL §2.4.1 Intrinsic Types). The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal VBA.
A Declare statement is not looked into: the types it states are the ones the external procedure takes, and are not the declaring module's to choose. Nor
are the parameters and the return type of a procedure that implements an interface member or handles an event, such as
UserForm_QueryClose(Cancel As Integer, CloseMode As Integer): they are the member's or the event's. What the body of such a procedure declares is reported. A user-defined type
that is read from or written to a file in a format that has 16-bit fields is a reason to keep an Integer; so is a procedure that must be called through a signature
that states it.
That a declaration states the type is a fact of the way it is written: the analyzer reads it off the syntax tree, and reports the As clause, or the name written with %.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A variable, a parameter, a return type or a field of a user-defined type is declared As Integer (or As VBA.Integer). |
Dim count As Integer |
Declare it As Long, unless a 16-bit value is what is needed. |
A variable, a constant, a parameter or a function is declared with a name that ends in %. The other type-declaration characters (&, ^, !, #, @, $) are not reported. |
Dim count% |
Declare it As Long, or with &: Dim count&. |
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca