1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 9 - Structured Error Handling

By , About.com Guide

6 of 10

About the New Tricks

Notice that I used a few new tricks here. VB 6 doesn't allow multiple variables to be declared As Type on the same line but VB.NET does. (With VB 6, X and Y would be Variant variables and only Z would be an Integer.) I also put two statements on the same line right after that. This doesn't change the way the program runs but it does save a little space in the program source listing. And I also used the built-in constants vbCrLf and vbTab to format the output a little bit.

Here's what the Debug Output window will display after you run the program (lines shortened to fit the web page):

~~~~~~~~~~~~~~~~~~~~~~~~~
caught exception
  System.OverflowException: Arithmetic operation
  resulted in an overflow. at
  WindowsApplication1.Form1.Button1_Click(Object sender,
  EventArgs e) in C:\WindowsApplication1\Form1.vb:line 62
~~~~~~~~~~~~~~~~~~~~~~~~~

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Trapping Errors Using Structured Error Handling

©2009 About.com, a part of The New York Times Company.

All rights reserved.