VBC09310 — Type mismatch
Severity: Error · Family: VBC (static semantics / abstract syntax tree) ·
Source metadata: VBCompileErrorInfo
A value is of a type that cannot be let-coerced to the type it is assigned to, passed as, or compared against.
MS-VBA reports the same error, at compile time and at run time: Type mismatch. The run-time error is VBR00013.
This code is raised by StaticSemantics, SetCoercionStaticSemantics, ObjectValueStaticSemantics, PrecompilerLiveBranchEvaluator.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| An operand or a value is of a type the operation or the target cannot take. | Dim n As Long: n = Array(1, 2) |
Convert, or use the right type. |
| An object whose default member returns an object is where a value of a declared type is expected (RD-VBAL §5.5.1.1). | n = New Holder, where Holder's default member is As Object |
Read the value of the object it returns (n = holder.Value.Value), or declare the default member with the type of its value. |
A subscript of an array is a LongLong (RD-VBAL §5.6.13), whatever its value. |
Dim ll As LongLong: Debug.Print a(ll) |
Convert it: a(CLng(ll)). |
A conditional-compilation condition is not a number or a Boolean, or does not evaluate. |
#If "a" Then, #If 1 / 0 Then |
Write a number or a Boolean expression. |
See also
⏮️ VBC09309 Label not defined | ⏭️ VBC09311 User-defined type not defined
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca