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

Procedure call or argument is not valid (Visual Basic)

6

Overflow (Visual Basic Error)

Overflow (Visual Basic Run-Time Error)

7

Out of memory (Visual Basic Compiler Error)

Out of memory (Visual Basic Run-Time Error)

9

Subscript out of range (Visual Basic)

10

This array is fixed or temporarily locked (Visual Basic)

11

Division by zero (Visual Basic Run-Time Error)

13

Type mismatch (Visual Basic)

14

Out of string space (Visual Basic)

16

Expression too complex

17

Can't perform requested operation (Visual Basic)

18

User interrupt occurred

20

Resume without error

28

Out of stack space (Visual Basic)

35

Sub or Function not defined (Visual Basic)

47

Too many DLL application clients

48

Error in loading DLL (Visual Basic)

49

Bad DLL calling convention

51

Internal error (Visual Basic)

52

Bad file name or number

53

File not found (Visual Basic Run-Time Error)

54

Bad file mode

55

File already open

57

Device I/O error

58

File already exists

59

Bad record length

61

Disk full (Visual Basic)

62

Input past end of file

63

Bad record number

67

Too many files

68

Device unavailable

70

Permission denied (Visual Basic)

71

Disk not ready

74

Cannot rename with different drive

75

Path/File access error

76

Path not found

91

Object variable or With block variable not set

92

For loop not initialized (Visual Basic)

93

Invalid pattern string

94

Invalid use of Null (obsolete, no longer used)

95

Application-defined or object-defined error

96

Unable to sink events of object because the object is already firing events to the maximum number of event receivers it supports

97

Cannot call friend function on object which is not an instance of defining class

98

A property or method call cannot include a reference to a private object, either as an argument or as a return value

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

File format not valid

322

Can't create necessary temporary file

325

Format not valid in resource file

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

Property value is not valid

381

Property array index is not valid

382

Set not supported at run time

383

Set not supported (read-only property)

385

Need property array index

387

Set not permitted

393

Get not supported at run time

394

Get not supported (write-only property)

400

Form already displayed; can't show modally

402

Code must close topmost modal form first

422

Property not found

423

Property or method not found

424

Object required (Visual Basic)

429

Cannot create ActiveX Component

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

Automation error

442

Connection to type library or object library for remote process has been lost

443

Automation object does not have a default value

445

Object doesn't support this action (Visual Basic)

446

Object doesn't support named arguments

447

Object doesn't support current locale setting (Visual Basic)

448

Named argument not found (Visual Basic)

449

Argument not optional (Visual Basic)

450

Wrong number of arguments or property assignment not valid

451

Property let procedure not defined and property get procedure did not return an object

452

Ordinal is not valid

453

Specified DLL function not found

454

Code resource not found

455

Code resource lock error

457

This key is already associated with an element of this collection

458

Variable uses an Automation type not supported in Visual Basic

459

Object or class does not support the set of events

460

Clipboard format is not valid

461

Method or data member not found

462

The remote server machine does not exist or is unavailable (Visual Basic)

463

Class not registered on local machine

481

Picture is not valid

482

Printer error

735

Cannot save file to TEMP

744

Search text not found

746

Replacements too long

999

Stop statement encountered

32768

Feature not yet implemented

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)

Err Object (Visual Basic)

Other Resources

Structured Exception Handling in Visual Basic