Re: Exceptions are not raised



Exceptions certainly *are* raised when they occur. However, in this case,
you're expecting a "divide by zero" exception, but it will not occur,
because in the .Net Platform, dividing by zero is not an illegal operation.
It results in "infinity."

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Giuseppe Chielli" <giuchiel@xxxxxxxxxxxxxxx> wrote in message
news:mMLYf.65484$PR2.1103327@xxxxxxxxxxxxxxxxxxxxx
Hi to everyone. I am studying VB.net and I am wondering why this trivial
code doesn't raise any exception:

Option Strict On

Imports System
Imports Microsoft.VisualBasic


Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim num1, num2 As Short
Dim num3 As Double
num1 = 5
num2 = 0
Try
num3 = num1 / num2
Catch ex As DivideByZeroException
MsgBox("Divisione per 0!")
End Try
End Sub

End Class

No msgbox is executed!!!
I'm using VB 2005 Express Edition.
Should I set anything in the framework or project properties?
Thanks in advance to everyone.

Giuseppe from Italy.


.



Relevant Pages

  • Re: fexception handling in C
    ... > I am using C on linux and performed a 1/0 operation i.e a divide by ... > zero using integer variables/constants.it gives me a floating point ... Interesting that you got a floating-point exception ...
    (comp.lang.c)
  • Re: TRAP 0000 in OS2KRNL
    ... That was a 'divide by zero' error where it wasn't dividing by zero. ... The meaning of the exception is actually 'divide overflow' - it's just that ... Further proof that you are a troll, ...
    (comp.os.os2.bugs)
  • Re: TRAP 0000 in OS2KRNL
    ... That was a 'divide by zero' error where it wasn't dividing by zero. ... The meaning of the exception is actually 'divide overflow' - it's just that ... But shouldn't the system protect itself from such a crash by ...
    (comp.os.os2.bugs)
  • Re: C to Delphi set problems
    ... In other words, it's undefined, and should throw an exception. ... to divide by zero. ... could be said for trying to find the lowest element in a set that is empty. ...
    (comp.lang.pascal.delphi.misc)
  • Re: INVALID_HANDLE_VALUE vs. NULL
    ... 0 (zero) can never be a valid handle value. ... Of course, ReadFilewill fail with this handle, ... > CloseHandle() does indeed fail when given a bad handle. ... > case it raises an exception. ...
    (microsoft.public.win32.programmer.kernel)