Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
VB.NET : Why doesn't FINALLY execute?
Old
  (#1)
Raymond Lesher
Guest
 
Posts: n/a
Default VB.NET : Why doesn't FINALLY execute? - 06-04-2007, 09:45 AM

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")

Finally
Console.WriteLine("Finally Block")

End Try

End Sub
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: VB.NET : Why doesn't FINALLY execute?
Old
  (#2)
Rick Rothstein
Guest
 
Posts: n/a
Default Re: VB.NET : Why doesn't FINALLY execute? - 06-04-2007, 09:46 AM

Almost everybody in this newsgroup is using VB6 or lower. While you may
get a stray answer to VB.NET questions here, you should ask them in
newsgroups devoted exclusively to .NET programming. Look for newsgroups
with either the word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups...

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general

There are some others, but these should get you started.

Rick - MVP



"Raymond Lesher" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED om...
> 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")
>
> Finally
> Console.WriteLine("Finally Block")
>
> End Try
>
> End Sub


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top