1 / 10

Finding & Fixing Errors

Finding & Fixing Errors. In Visual Basic 5.0. Programming errors come in three varieties:. Compile errors Run-time errors Logic errors. As VB attempts to convert your project code to machine language (called compiling the code) it finds any compile errors. You get compile errors when:.

obelia
Download Presentation

Finding & Fixing Errors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Finding & Fixing Errors In Visual Basic 5.0

  2. Programming errors come in three varieties: • Compile errors • Run-time errors • Logic errors

  3. As VB attempts to convert your project code to machine language (called compiling the code) it finds any compile errors. You get compile errors when: You break syntax rules of Basic & sometimes when you use an illegal object or property (eg: ennd, Quit rather than End) use wrong punctuation or place the punctuation in the wrong place (eg: lblMessage,Caption) Compile Errors

  4. Compile Errors (cont’d) • May be found by the editor as you move off the offending line or the compile error may not be found until you try to run the program • Inconsistent spelling of object names is most common compile error (eg: if you set a label control’s Name property to lblMessage, you MUST ALWAYS refer to it with that exact spelling!!)

  5. Run-Time Errors • If your project halts during execution, that’s a run-time error • A dialog box will be displayed, goes into break time, and highlights the statement causing the problem • Usually caused by attempting to do impossible arithmetic operations: calculate with nonnumeric data, divide by zero, finding the square root of a negative number

  6. Logic Errors • Your project runs but produces incorrect results… • Perhaps the results of a calculation are incorrect (incorrect formulas) or the wrong text appears or the text is OK but appears in the wrong location. • May need to use a calculator to check the output, or computations, text, spacing

  7. Project Debugging • Programs don’t really have errors in them…they get “bugs”…finding & fixing these bugs is called debugging • VB will display the Code window with the offending line highlighted for compile & run-time errors • Must locate logic errors yourself • Remember you also have VB Help at your disposal!

  8. How to find your errors • Check for spelling errors within your program. • Check you are using the same name in the program as the variable you defined (Dim…) • Check you have defined the variable (Dim…) and that is of the correct type (remember, integers in VB only go to ~32,000!

  9. To solve logic errors • Create extra labels and display other values as you go. • If you use variables that are never shown, display those in extra labels • When the program works, delete the labels and code • Keep a complete list of remarks so you can delete all codes associated with the extra labels - lblExtra.captions=... etc.

  10. Most importantly: Go one step at a time! Determine a value and display it. When that WORKS, determine the next value. DO NOT ask for help for a program that is completed but where the 1st step doesn’t work!!!!!!! I will not help you debug in this situation.

More Related