VBC09323 — Wrong number of arguments or invalid argument for event
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
The arguments of a RaiseEvent statement are not compatible with the parameter list of the event it raises.
MS-VBAL §5.4.2.20 RaiseEvent Statement requires the event's parameter list to be compatible with the argument list according to the rules of procedure invocation (MS-VBAL §5.3.1.11), all parameters and arguments being treated as positional.
This code is raised by
StatementStaticSemanticsEvaluator. The
verbose detail says how many arguments the event takes and how many were given.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| Fewer arguments than the event's required parameters. | RaiseEvent Changed for Event Changed(ByVal Value As Long) |
Pass the argument: RaiseEvent Changed(1). |
| More arguments than the event has parameters. | RaiseEvent Closed(1) for Event Closed() |
Remove the extra argument, or declare the parameter on the event. |
A variable passed to a ByRef parameter is not of exactly its type. |
RaiseEvent Bump(anInteger) for Event Bump(ByRef Count As Long) |
Pass a variable of the parameter's type. A value, RaiseEvent Bump(5), is Let-assigned to a new local and needs none. |
| An object parameter is given something that is not an object. | RaiseEvent ShapeOf(aLong) for Event ShapeOf(ByVal S As Gadget) |
Pass an object of a class, or Object; a ByVal parameter takes a Variant too, a ByRef one does not. |
An argument that cannot be Let-coerced to the type of a ByVal parameter is reported with the code of that coercion
(VBC09310, type mismatch), not with this one.
Notes
Arguments are positional only: a RaiseEvent has no named arguments. An event's parameters do not define variables; they
describe the arguments the statement must provide, and the parameter list a handler must have.
See also
- VBC09322 — the event is not one the class module declares
- RD-VBAL §2.6.2 Semantic Compilation Errors
- RD-VBAL §5.4.2.20 RaiseEvent Statement
⏮️ VBC09322 Event not defined | ⏭️ VBC09324 Invalid type for WithEvents variable
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca