Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 40,514 times

Contents

Related Categories

Error Handling - Introduction

Introduction

When you create an application, there are certain unknown elements. For example, if the users tries to save the current file which is on a floppy, and the floppy is not inserted when your application attempts to access it, your application will crash and you would lose any unsaved information. Error handling intercepts these errors, so you can give the user a useful error message, instead of your application crashing. i.e. instead of getting a message "Err 45 Disk not ready" and then the application crashing, you could change your code so that the user would get the message "Please insert a floppy disk into Drive A", and then give the user an option to retry or cancel.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • My error handling

    Posted by MathiasRav on 26 May 2004

    Sometimes, I use a module to take care of error handling:

    [code]Option Explicit

    Sub ErrHandl(Error As ErrObject)
    Dim S As String
    Dim D As Date
    Dim TimeS As String
    D = Now
    ...

  • Careful there

    Posted by HyperHacker on 27 Jul 2003

    Most people don't notice this, but if you have error-handling code at the end of a sub/function, you have to place Exit Sub or Exit Function before it, or it'll execute the error handler afterward eve...

  • Be careful with resume next

    Posted by mmarrero on 10 Apr 2002

    Resume Next will execute the next statement, even if it's inside an IF statement. Worse of all, VB/VBscript evaluates the whole expression.

    Public Function test2()
    On Error Resume Next
    If (1 ...