Trappable Errors in Visual Basic
While the structured exception handling model provided in Visual Basic is more useful in developing applications, you might choose to employ unstructured error handling, particularly when upgrading legacy applications. You can use the On Error Statement (Visual Basic) to trap and respond to specific errors.
Trappable Errors
Trappable errors can occur while an application is running. Some trappable errors can also occur during development or compile time. You can test and respond to trappable errors using the On Error statement and the Err Object (Visual Basic).
The following table lists error codes and their associated messages.
Code |
Message |
---|---|
0 |
No error |
3 |
Return without GoSub (obsolete, no longer used) |
5 |
|
6 |
|
7 |
|
9 |
|
10 |
|
11 |
|
13 |
|
14 |
|
16 |
|
17 |
|
18 |
|
20 |
|
28 |
|
35 |
|
47 |
|
48 |
|
49 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
57 |
|
58 |
|
59 |
|
61 |
|
62 |
|
63 |
|
67 |
|
68 |
|
70 |
|
71 |
|
74 |
|
75 |
|
76 |
|
91 |
|
92 |
|
93 |
|
94 |
Invalid use of Null (obsolete, no longer used) |
95 |
|
96 |
|
97 |
Cannot call friend function on object which is not an instance of defining class |
98 |
|
100 |
Class '<classname>' does not implement the System.Collections.ICollection interface |
298 |
System resource or DLL could not be loaded |
320 |
Cannot use character device names in specified file names |
321 |
|
322 |
|
325 |
|
327 |
Data value named not found |
328 |
Illegal parameter; can't write arrays |
335 |
Could not access system registry |
336 |
ActiveX component not correctly registered |
337 |
ActiveX Component not found |
338 |
ActiveX Component did not run correctly |
360 |
Object already loaded |
361 |
Can't load or unload this object |
363 |
ActiveX Control specified not found |
364 |
Object was unloaded |
365 |
Unable to unload within this context |
368 |
The specified file is out of date |
371 |
The specified object can't be used as an owner form for Show |
380 |
|
381 |
|
382 |
|
383 |
|
385 |
|
387 |
|
393 |
|
394 |
|
400 |
Form already displayed; can't show modally |
402 |
Code must close topmost modal form first |
422 |
|
423 |
|
424 |
|
429 |
|
430 |
Class does not support Automation or does not support expected interface |
432 |
File name or class name not found during Automation operation (Visual Basic) |
438 |
Object doesn't support this property or method (Visual Basic) |
440 |
|
442 |
Connection to type library or object library for remote process has been lost |
443 |
|
445 |
|
446 |
|
447 |
Object doesn't support current locale setting (Visual Basic) |
448 |
|
449 |
|
450 |
|
451 |
Property let procedure not defined and property get procedure did not return an object |
452 |
|
453 |
|
454 |
|
455 |
|
457 |
This key is already associated with an element of this collection |
458 |
Variable uses an Automation type not supported in Visual Basic |
459 |
|
460 |
|
461 |
|
462 |
The remote server machine does not exist or is unavailable (Visual Basic) |
463 |
|
481 |
|
482 |
|
735 |
|
744 |
|
746 |
|
999 |
|
32768 |
The message Application-defined or object-defined error applies to an error code that Visual Basic does not recognize.
See Also
Tasks
Troubleshooting Exception Handling
Concepts
Introduction to Exception Handling
Unstructured Exception Handling Overview
Choosing When to Use Structured and Unstructured Exception Handling
Reference
On Error Statement (Visual Basic)