1001 1007




Visual Basic 6 Black Book:Error Handling And Debugging
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Black Book (Publisher: The Coriolis Group) Author(s): Steven Holzner ISBN: 1576102831 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




Chapter 29Error Handling And Debugging


If you need an immediate solution to:
Writing Error Handlers
Using On Error GoTo Label
Using On Error GoTo line#
Using On Error Resume Next
Using On Error GoTo 0
Using Resume In Error Handlers
Using Resume Label In Error Handlers
Using Resume line# In Error Handlers
Using Resume Next In Error Handlers
Getting An Error’s Error Code
Getting An Error’s Description
Determining An Error’s Source Object
Handling Errors In DLLs: The LastDLLError Property
Creating An Intentional (User-Defined) Error
Nested Error Handling
Creating An Error Object Directly In Visual Basic
Trappable Cancel Errors In Common Dialogs
Debugging In Visual Basic
Setting Debugging Breakpoints
Single-Stepping While Debugging
Examining Variables And Expressions
Adding Debug Watch Windows
Using The Immediate Window While Debugging
Clearing All Debugging Breakpoints
Executing Code Up To The Cursor While Debugging
Skipping Over Statements While Debugging

In Depth
This is our chapter on runtime errors and bugs. With a process called trapping, Visual Basic lets you catch many runtime errors, and we’ll see how to do that here. And when we catch a runtime error, we’ll see how to recover from that error without crashing the program. Just about every Visual Basic programmer is familiar with bugs—they’re those annoying logic errors that occur when what the computer does doesn’t appear to be the same as what you asked it to do. We’ll ferret out bugs in this chapter with the Visual Basic debugger.
We’ll also see how to get and interpret error codes—including translating them to English, how to write error handlers, how to use the Resume statement to continue program execution, and quite a few other powerful topics. Handling runtime errors is usually a part of any commercially released Visual Basic program because Visual Basic handles runtime errors by displaying information only useful to the programmer. Visual Basic lets you handle runtime errors by trapping them with special code, and these errors are referred to as trappable errors. You’ll find a list of the Visual Basic trappable errors in Table 29.1.
Table 29.1 The Visual Basic trappable error codes and messages.

Code
Message

3
Return without GoSub

5
Invalid procedure call

6
Overflow

7
Out of memory

9
Subscript out of range

10
This array is fixed or temporarily locked

11
Division by zero

13
Type mismatch

14
Out of string space

16
Expression too complex

17
Can’t perform requested operation

18
User interrupt occurred

20
Resume without error

28
Out of stack space

35
Sub, Function, or Property not defined

47
Too many code resource or DLL application clients

48
Error in loading code resource or DLL

49
Bad code resource or DLL calling convention

51
Internal error

52
Bad file name or number

53
File not found

54
Bad file mode

55
File already open

57
Device I/O error

58
File already exists

59
Bad record length

61
Disk full

62
Input past end of file

63
Bad record number

67
Too many files

68
Device unavailable

70
Permission denied

71
Disk not ready

74
Can’t 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

93
Invalid pattern string

94
Invalid use of Null

97
Can’t call Friend procedure on an object that is not an instance of the 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

298
System resource or DLL could not be loaded

320
Can’t use character device names in specified file names

321
Invalid file format

322
Can’t create necessary temporary file

325
Invalid format 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. This program requires a later version

371
The specified object can’t be used as an owner form for Show

380
Invalid property value

381
Invalid property-array index

382
Property Set can’t be executed at runtime

383
Property Set can’t be used with a read-only property

385
Need property-array index

387
Property Set not permitted

393
Property Get can’t be executed at runtime

394
Property Get can’t be executed on write-only property

400
Form already displayed; can’t show modally

402
Code must close topmost modal form first

419
Permission to use object denied

422
Property not found

423
Property or method not found

424
Object required

425
Invalid object use

429
ActiveX Component can’t create object or return reference to this object

430
Class doesn’t support Automation

432
File name or class name not found during Automation operation

438
Object doesn’t support this property or method

440
Automation error

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

443
Automation object doesn’t have a default value

445
Object doesn’t support this action

446
Object doesn’t support named arguments

447
Object doesn’t support current locale setting

448
Named argument not found

449
Argument not optional or invalid property assignment

450
Wrong number of arguments or invalid property assignment

451
Object not a collection

452
Invalid ordinal

453
Specified DLL function code resource 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 a type not supported in Visual Basic

459
This component doesn’t support the set of events

460
Invalid Clipboard format

461
Specified format doesn’t match format of data

480
Can’t create AutoRedraw image

481
Invalid picture

482
Printer error

483
Printer driver does not support specified property

484
Problem getting printer information from the system. Make sure the printer is set up correctly

485
Invalid picture type

486
Can’t print form image to this type of printer

520
Can’t empty Clipboard

521
Can’t open Clipboard

735
Can’t save file to TEMP directory

744
Search text not found

746
Replacements too long

31001
Out of memory

31004
No object

31018
Class is not set

31027
Unable to activate object

31032
Unable to create embedded object

31036
Error saving to file

31037
Error loading from file


TIP:  Getting “out of memory” errors has driven more than one programmer to distraction, How can I be out of memory? I have 512MB of RAM! In fact, Microsoft sometimes treats this error as a generic error, and programs can issue this error when the actual error cause is unknown.

With regard to debugging, Visual Basic provides programmers with a set of tools that is hard to beat. You can debug your programs interactively, working through your code line by line as the program runs. This powerful technique lets you work behind the scenes in a way that is invaluable to finding out what’s going wrong. You can also specify where to begin debugging a program with breakpoints, which are lines of code that you tag to make the program halt and debugging start.
In this chapter, we’ll see how to set and use breakpoints, execute code line by line, execute code up to a specified line, watch variables as they’re changing, and more. Taking care of your program’s bugs before you release it is important—the user might be able to handle runtime errors with the aid of our error handlers, but not errors in program logic.



Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
1001 1
1007 1010
IndeksyGPW 1007
Braun golarka męska Entry, 100, 105, 1007, 1008, 1012, 1013 instrukcja obsługi
art 1007 s11427 012 4407 7
1367264164 1001 12534
1403255290 1001 31075

więcej podobnych podstron