Error  Handler

Posted on 2004-11-29
Last Modified: 2010-04-24
How would you handle:
99999 +99999 = 'System.OverflowException'
' 9 divide 0' = infinity
99 * 999 = 'System.OverflowException'
32000 - -768 = you will get an exception
Question by:Barako2
    1 Comment
    LVL 9

    Accepted Solution

    You decide how to handle each of those errors using "Try...Catch" blocks:

    dim i as int16
         i = 99999 +99999
    catch ex as System.OverflowException
         'Inside the Catch Block, you put code that you want to execute if something goes wrong.  Here, we're capturing only an OverflowException.
         i = nothing
         messagebox.Show("Sorry, I can't add that hight.")
    catch genEx as System.Exception
         'Here, I'm catching any other exceptions that may have occured other than the OverflowException
          i = nothing
"An error occurred." & vbCrLf & genEx.message)
    end Try

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now