Errors and Debugging. Learn how to make errors Syntax Compile Run-time Semantic Cn’t type Can’t rememb Can’t decide Can’t think.

Slides:



Advertisements
Similar presentations
Integrated Business Applications with Databases (D3) Jenny Pedler
Advertisements

Customisation The GUI in most GIS applications is sufficient for most needs. However, situations arise where you want either to: –Modify the interface,
© 1999, by Que Education and Training, Chapter 6, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
© 2005 Wellesley Information Services. All rights reserved. Error Handling in LotusScript Agents Chuck Connell CHC-3 Consulting.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Decision making in VBA. Current Event Occurs: When a form is opened When the focus leaves one record and moves to another Before the first or next record.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Trapping Errors and Debugging Code. Programming errors can vary by … Type Cause Effect Severity Other factors Error types Include Syntax Logic Compile.
Error Trapping Part II Runtime Errors Error Handling Conclusion Questions Syntax Errors Error Categories Logic Errors Debugging Tools The Err Object Error.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Finding and Debugging Errors
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
How to Debug VB .NET Code.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
JavaScript, Fourth Edition
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Topics Built-in functions commonly used in business applications String functions and formatting Dates and Times Formatting Data for output Error handling.
Private Sub Close_Click() On Error GoTo Err_Close_Click DoCmd.Close Exit_Close_Click: Exit Sub Err_Close_Click: MsgBox Err.Description Resume Exit_Close_Click.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
Slides Credit Umair Javed LUMS Web Application Development.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Visual Basic: An Object Oriented Approach 5: Structured Programming.
Programming Intro Problem Solving: 1)Understand the problem This often involves breaking the problem into manageable pieces 2) Develop a plan May develop.
Chapter 2: Creating ActiveX Code Components By นภดล กมลวิลาศเสถียร Dept. of Computer Engineering, Prince of Songkla University Source: Mastering Visual.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
General Programming Introduction to Computing Science and Programming I.
Errors Part I Error Messaging Error Handling Conclusion Questions What is an Error What is VBA Types of Errors Error Commands Error Flow Error Trapping.
October, 2006 © Copyright 2006, Larry A. Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is preserved.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
ME 142 Engineering Computation I Debugging Techniques.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
The C# language fundamentals ( II ) Po Feng, Tsai.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
1 CS 106 Computing Fundamentals II Chapter 81 “Error Handling” Herbert G. Mayer, PSU CS status 6/14/2013 Initial content copied verbatim from CS 106 material.
Lecture 4 Programming Technique Programming Appreciation.
Preparing for Assignment 3. Setup Assignment 3 builds on Assignment 2, and we are using the same basic scenario. Save the spreadsheet you used for Assignment.
Centric features In this presentation… –macro capabilities more sophisticated functionality –advanced macro features Inspector Debugging error trapping.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
CS212: Object Oriented Analysis and Design Lecture 19: Exception Handling.
5.01 Understand Different Types of Programming Errors
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Introduction to Exceptions in Java CS201, SW Development Methods.
Program Control: Selection Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
Lecture 6 – Working with VBA Sub Procedures Dr Joanna Wyrobek 1.
Debugger By: Engr. Faisal ur Rehman CE-105 Spring 2007.
FOP: Multi-Screen Apps
Java Exceptions a quick review….
Introduction to Computing Science and Programming I
5.01 Understand Different Types of Programming Errors
Programming in visual basic .net Visual Basic Building Blocks
ME 142 Engineering Computation I
Microsoft Access 2003 Illustrated Complete
Microsoft Access Illustrated
Excel VBA Day 3 of 3 Tom Vorves.
5.01 Understand Different Types of Programming Errors
Exception Handling In Text: Chapter 14.
Tonga Institute of Higher Education
Exceptions.
Problems Debugging is fine and dandy, but remember we divided problems into compile-time problems and runtime problems? Debugging only copes with the former.
Microsoft Visual Basic 2005 BASICS
Chapter 8 - Visual Basic Schneider
Finishing Up.
Exception Handling.
Presentation transcript:

Errors and Debugging

Learn how to make errors Syntax Compile Run-time Semantic Cn’t type Can’t rememb Can’t decide Can’t think

Intercept Errors Before VBA Utilities must have error handling Anticipate errors in important components On Error GoTo Resume ExitStageLeft

On Error, whaaaat? On Error Goto 0 –Disables the error handler On Error Resume Next –Ignore the error and continue On Error Goto Label –Jump to Label: for your own code to handle

Polishing off your Resume Resume –Suggested only for run-time debugging!! Resume Next –Just keep on running after error detected, don’t report the error at all. Resume Label –Best. Go to Label: when error detected

Trap for the “Usual suspects” If you know division by zero is possible –If Err.Number = 11 Then yadda yadda If you know data type can be wrong –If Err.Number = 13 Then yadda yadda How to know Err.Number? MsgBox Err.Number & ": " & Err.Description Resume Exit_Label Here is where your own code can handle the errors

VBA Run-time Error Objects Trap-able Err object Err.Number Err.Description Err.Source (MSAccess)

Custom Traps Prevent user errors by making them yourself If not IsDate(dteUser) Then _ Err.Raise If not IsNumeric(varUser) Then _ Err.Raise Err.Raise can promote errors to calling Procs.

Form-level Errors In Form event “OnError” Assignment2.mdb Response arg controls Access err msgs acDataErrContinue (override err msgs) acDataErrDisplay (allow err msgs) Issue your own err msgs: If ActiveControl.Name = "txtDate" then… If ActiveControl.Name = "cboParty" then…

Compile-time errors Occur before run-time errors Find these on purpose Menu selections: Debug, Compile

ADO Run-time error collection Trap-able Can be same error numbers as VBA When same, error belongs to ADO Useful in debugging linked tables Useful in client-server situations Example: frmErrorHandling –Sub ShowErrors()

When are errors reported? Sometimes, when they are caused Sometimes, where they are caused Error handling routine chained back to callers “Resume” can be dangerous in chains Best to trap in individual Procs… unless… Subordinate procs return errors for supervisor Proc

Debugging Calm demeanor is essential Take a totally objective view “What does this statement do?” (right!) “What should this statement do?” (wrong!) Cardinal rule: get more information

Techniques Break points, F8 Hover Run to cursor Watch, QuickWatch Run and Re-run lines of code

Design-time tools Bulk commenting Bookmarking source