VBC09342: Wrong number of arguments or invalid property assignment
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
A procedure is called with arguments it does not declare.
The call gives more arguments than the procedure declares parameters, or names an argument when the procedure declares none.
MS-VBA reports the same error, with the same message (recorded in Excel).
This code is raised by ObjectValueStaticSemantics.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| Too many arguments. | c.Increment 1 of a Sub Increment() |
Remove the extra arguments, or declare the parameters. |
| An argument for a property that takes none. | Debug.Print c.Count(1) of a Count that returns a Long |
Read the property without arguments. |
| An argument for a function that takes none and returns an array. | x = F(1) of a Function F() As Long() |
Index what it returns with a second argument list: x = F()(1). |
| One argument too many for a function that returns an array. | x = G(1, 0) of a Function G(n As Long) As Long() |
x = G(1)(0). |
Notes
A Function or Property Get that declares no parameters and returns a Variant or an object is not given the arguments: they index what it returns (Letters(1)). Through an object declared As Object or Variant, the call compiles, and raises error 450 when it runs.
One that returns an array is given them, as MS-VBA gives them (recorded in Excel, oracle\s55 A01, A04), though MS-VBAL §5.6.13 lets them index the array. See RD-VBAL §5.6.13.
See also
- RD-VBAL §5.6.13 Index Expressions
- RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing
- RD-VBAL §2.6.2 Semantic Compilation Errors
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca