home *** CD-ROM | disk | FTP | other *** search
- '+==========================================================================
- ' File: TestExcept.cls
- '
- ' Summary: This file implements the TestExcept class
- '
- ' Classes: TestExcept
- '
- ' Functions: CustomException, TestDivideByZero, TestNullReferenceException
- '
- '----------------------------------------------------------------------------
- ' This file is part of the Microsoft NGWS Samples.
- '
- ' Copyright (C) 1998-2000 Microsoft Corporation. All rights reserved.
- '==========================================================================+
- Option Strict Off
-
- Imports System
- Imports Microsoft.VisualBasic
-
- NameSpace MyTestException
- Public Class TestExcept
-
- '******************************************************************************
- 'Function : CustomException(ByVal bThrowException As Boolean) As String
- '
- 'Abstract: It does nothing, just prints out the Method name, unless
- ' bThrowException is true, in which case, MyCustomException is thrown.
- '
- 'Input Parameters: Boolean (if true, this function throws a MyCustomException)
- '
- 'Returns: String
- '******************************************************************************
- Public Function CustomException(ByVal bThrowException As Boolean) As String
- Console.WriteLine ("VB TestExcept.CustomException")
- If bThrowException Then
- Dim Except as MyCustomException
- Except = New MyCustomException()
- Throw (Except)
- End If
-
- CustomException = "Done...Not Thrown CustomException"
- End Function
-
- '******************************************************************************
- 'Function : TestDivideByZero(ByVal bThrowException As Boolean) As String
- '
- 'Abstract: It does nothing, just prints out the Method name, unless
- ' bThrowException is true, in which case, a DivideByZeroException is
- ' thrown.
- '
- 'Input Parameters: Boolean (if true, this function throws a MyCustomException)
- '
- 'Returns: String
- '******************************************************************************
- Public Function TestDivideByZero(ByVal bThrowException As Boolean) As String
- Console.WriteLine ("VB TestExcept.TestDivideByZero")
- If bThrowException Then
- Dim x As Integer
- Dim y As Integer
- x = 0
- y = 5 / x
- Console.WriteLine (y)
- End If
-
- TestDivideByZero = "Done...Not Thrown TestDivideByZero"
- End Function
-
- '******************************************************************************
- 'Function : TestNullReferenceException(ByVal bThrowException As Boolean) As String
- '
- 'Abstract: It does nothing, just prints out the Method name, unless
- ' bThrowException is true, in which case, a NullReferenceException is
- ' thrown.
- '
- 'Input Parameters: Boolean (if true, this function throws a MyCustomException)
- '
- 'Returns: String
- '******************************************************************************
- Public Function TestNullReferenceException(ByVal bThrowException As Boolean) As String
- Console.WriteLine ("VB TestExcept.TestNullReferenceException")
- Dim o as String
- If bThrowException Then
- Dim i as Integer
- i = o.Length
- End If
-
- TestNullReferenceException = "Done...Not Thrown TestNullReferenceException"
- End Function
- End Class
- End Namespace