Вы находитесь на странице: 1из 2

Exception Handling 1. Structure exception handling a. Try catch 2. Unstructured exception handling a. On error goto next b.

. On error goto 0 c. On error resume next

Example 1

On Error GoTo first Dim x, y, z As Integer x = InputBox("enter the number ", "ssi", 0) y = InputBox("enter the second number ", "ssi", 1) z = x / y MessageBox.Show(" answer is " & z, "ssi", MessageBoxButtons.OK, MessageBoxIcon.Hand) Exit Sub first: MsgBox(Err.Description)

Example 2

On Error GoTo 0 Dim x, y, z As Integer x = InputBox("enter the number ", "ssi", 0) y = InputBox("enter the second number ", "ssi", 1) z = x / y MessageBox.Show(" answer is " & z, "ssi", MessageBoxButtons.OK, MessageBoxIcon.Hand) Exit Sub first: MsgBox(Err.Description)

Example 3

On Error Resume Next Dim x, y, z As Integer x = InputBox("enter the number ", "ssi", 0)

y = InputBox("enter the second number ", "ssi", 1) z = x / y MessageBox.Show(" answer is " & z, "ssi", MessageBoxButtons.OK, MessageBoxIcon.Hand)

Example 4

Try Dim x, y, z As Integer x = InputBox("enter the number ", "ssi", 0) y = InputBox("enter the second number ", "ssi", 1) z = x / y MessageBox.Show(" answer is " & z, "ssi", MessageBoxButtons.OK, MessageBoxIcon.Hand) Catch ex As Exception MsgBox(ex.ToString) End Try

Вам также может понравиться