Yeah, that was my mistake. Long story short, I was under the
impression that 1/0 generated an error in vb.net like it does in c#,
but it doesn't. I tested the code sample via c# not vb.net. My
mistake.
My goal is to raise an error in the try. In this case, a better
example would have been "throw new system.exception" instead of "x = 1
/ 0".
Under the hopefully guarenteed error being raised I then run into the
finally not be executed in both situations.
Thank you for responding.
-Ray
"M. Posseth" <mi*****@nohausystems.nl> wrote in message news:<cf**********@reader13.wxs.nl>...
Well i just pasted this code in my dev environment ( VS.NET 2003
Enterprise ) and it does execute in bot both situations
so ..... ???????
Happy coding
M. Posseth [MCP]
"Raymond Lesher" <rl****@hotmail.com> wrote in message
news:47*************************@posting.google.co m... Oops! Forgot a line of code!!!!! Sorry. This code example should
display my problem properly.
Why does the finally clause in the Test method (below) NOT execute in
my "foo" example, but DOES execute in my "bar" example?
'Test-Finally does NOT execute
Private Sub foo()
Test()
End Sub
'Test-Finally DOES execute
Private Sub bar()
Try
Test()
Catch ex As Exception
End Try
End Sub
Private Sub Test()
Dim x As Double
Try
x = 1 / 0
Catch ex As Exception
Console.WriteLine("Exception Block")
Throw ex
Finally
Console.WriteLine("Finally Block")
End Try
End Sub