2.6.3 Runtime Errors
A runtime error is raised by the runtime semantics layer and left unhandled by workspace code. Examples are a subscript out of range, a type-mismatch coercion, and division by zero.
| Code family | VBR; the numeric portion matches the corresponding MS-VBA run-time error code |
| Title | Run-time error |
| Raised by | the runtime semantics layer |
| Source metadata | VBRuntimeErrorInfo; its identifier is a VBRuntimeErrorId whose numeric value corresponds to its MS-VBAL specified error code |
| Severity | Error |
Regardless of the error message content, RD-VBA must still raise the MS-VBA equivalent error code in the relevant contexts (e.g. VBR00461 MethodOrDataMemberNotFound, whose message uses the term "data member"; see RD-VBAL §2.4.2 Non-intrinsic Types).
InternalError is never reported for a language-level condition that a well-formed program meets; such a condition raises a run-time error.
On a run-time error, the interactive shell renders an icon, the title with the program's own line number, the diagnostic code and description, Err.Source, and the stack trace; see RD-VBAL §2.0.2 Client/Server Capabilities.
Run-time Errors Reported Before the Code Runs
A run-time error that an instruction raises whenever it runs is a fact about the code, and is reported as a diagnostic of the runtime phase without the program
being run: Dim n As Byte then n = 5678 is VBR00006 (Overflow) on the assignment, in an editor and in the shell's ANALYZE. The environment host finds it by
evaluating every instruction of every procedure once, through the runtime semantics, and states it only when nothing the instruction did was assumed (a variable,
a call it does not make, the state of the library or of the outside world, the state another instruction left behind); see
RD-VBAL §2.6.4 Rubberduck Core Diagnostics. An error the code raises for itself is not reported: Error 5 is
what the statement is there to do.
Run-time Errors Referenced by Statement Semantics
| Error | VBRuntimeErrorId |
Raised when | See |
|---|---|---|---|
| 13 | TypeMismatch |
For Each over anything other than an array or an object (a scalar) |
RD-VBAL §5.4.2.4 For Each Statement |
| 91 | ObjectVariableOrWithBlockVariableNotSet |
For Each over Nothing (invoking _NewEnum on an unset reference) |
RD-VBAL §5.4.2.4 For Each Statement |
| 92, "For loop not initialized" | ForLoopNotInitialized |
a ForNext or ForEachNext with no stored loop state (a GoTo landing directly on the closer), or a For Each over an array that was never dimensioned |
RD-VBAL §5.4.2.3 For Statement, RD-VBAL §5.4.2.4 For Each Statement |
| 438 | ObjectDoesntSupportThisPropertyOrMethod |
For Each over a live object with no VB_UserMemId = -4 member |
RD-VBAL §5.4.2.4 For Each Statement |
The verbose message for ForLoopNotInitialized is the resx entry VBForLoopNotInitialized_Verbose when a Next closer runs without its opener, and VBForEach_ArrayNotInitialized_Verbose when a For Each enumerates a never-dimensioned array; both are provided in both languages.
Published Run-time Errors
| Code | Error |
|---|---|
VBR-0001 |
Application-defined or object-defined error |
VBR00003 |
Return without GoSub |
VBR00005 |
Invalid procedure call or argument |
VBR00006 |
Overflow |
VBR00007 |
Out of memory |
VBR00009 |
Subscript out of range |
VBR00010 |
This array is fixed or temporarily locked |
VBR00011 |
Division by zero |
VBR00013 |
Type mismatch |
VBR00014 |
Out of string space |
VBR00016 |
Expression too complex |
VBR00017 |
Can't perform requested operation |
VBR00018 |
User interrupt occurred |
VBR00020 |
Resume without error |
VBR00028 |
Out of stack space |
VBR00035 |
Sub or Function not defined |
VBR00047 |
Too many DLL application clients |
VBR00048 |
Error in loading DLL |
VBR00049 |
Bad DLL calling convention |
VBR00051 |
Internal error |
VBR00052 |
Bad file name or number |
VBR00053 |
File not found |
VBR00054 |
Bad file mode |
VBR00055 |
File already open |
VBR00057 |
Device I/O error |
VBR00058 |
File already exists |
VBR00059 |
Bad record length |
VBR00061 |
Disk full |
VBR00062 |
Input past end of file |
VBR00063 |
Bad record number |
VBR00067 |
Too many files |
VBR00068 |
Device unavailable |
VBR00070 |
Permission denied |
VBR00071 |
Disk not ready |
VBR00074 |
Can't rename with different drive |
VBR00075 |
Path/File access error |
VBR00076 |
Path not found |
VBR00091 |
Object variable or With block variable not set |
VBR00092 |
For loop not initialized |
VBR00093 |
Invalid pattern string |
VBR00094 |
Invalid use of Null |
VBR00096 |
Unable to sink events of object because the object is already firing events to the maximum number of event receivers that it supports |
VBR00097 |
Can not call friend function on object which is not an instance of defining class |
VBR00098 |
A property or method call cannot include a reference to a private object, either as an argument or as a return value |
VBR00321 |
Invalid file format |
VBR00322 |
Can't create necessary temporary file |
VBR00325 |
Invalid format in resource file |
VBR00380 |
Invalid property value |
VBR00381 |
Invalid property array index |
VBR00382 |
Set not supported at runtime |
VBR00383 |
Set not supported (read-only property) |
VBR00385 |
Need property array index |
VBR00387 |
Set not permitted |
VBR00393 |
Get not supported at runtime |
VBR00394 |
Get not supported (write-only property) |
VBR00422 |
Property not found |
VBR00423 |
Property or method not found |
VBR00424 |
Object required |
VBR00429 |
ActiveX component can't create object |
VBR00430 |
Class does not support Automation or does not support expected interface |
VBR00432 |
File name or class name not found during Automation operation |
VBR00438 |
Object doesn't support this property or method |
VBR00440 |
Automation error |
VBR00442 |
Connection to type library or object library for remote process has been lost. Press OK for dialog to remove reference. |
VBR00443 |
Automation object does not have a default value |
VBR00445 |
Object doesn't support this action |
VBR00446 |
Object doesn't support named arguments |
VBR00447 |
Object doesn't support current locale setting |
VBR00448 |
Named argument not found |
VBR00449 |
Argument not optional |
VBR00450 |
Wrong number of arguments or invalid property assignment |
VBR00451 |
Property let procedure not defined and property get procedure did not return an object |
VBR00452 |
Invalid ordinal |
VBR00453 |
Specified DLL function not found |
VBR00454 |
Code resource not found |
VBR00455 |
Code resource lock error |
VBR00457 |
This key is already associated with an element of this collection |
VBR00458 |
Variable uses an Automation type not supported in Visual Basic |
VBR00459 |
Object or class does not support the set of events. |
VBR00460 |
Invalid clipboard format |
VBR00461 |
Method or data member not found |
VBR00462 |
The remote machine does not exist or is unavailable |
VBR00463 |
Class not registered on local machine |
VBR00481 |
Invalid picture |
VBR00482 |
Printer error |
VBR00735 |
Can't save file to TEMP |
VBR00744 |
Search text not found |
VBR00746 |
Replacements too long |
Application Errors
An application error is a custom run-time error explicitly raised from workspace source code with Error or Err.Raise; see RD-VBAL §5.4.4.3 Error Statement and RD-VBAL §6.1.3.2 Err Class. MS-VBAL does not distinguish an application error from a semantic run-time error.
| Code family | VBA, a pseudo-code; the numeric portion matches the application-supplied error code |
| Title | Application error |
| Raised by | workspace source code (Error or Err.Raise) |
| Source metadata | VBApplicationErrorInfo |
| Severity | Error |
RDCore removes the need for the vbObjectError constant by internally representing run-time errors and application errors as different error metadata types; see RD-VBAL §1.1.4 Core Diagnostics.
⏮️ RD-VBAL §2.6.2 Semantic Compilation Errors | ⏭️ RD-VBAL §2.6.4 Rubberduck Core Diagnostics