Try Catch Quesiton Again

P

Peter Huang

Hi Brian,

Thanks for posting in the community.

Module Module3
Public Function Func(ByVal isEx As Boolean) As Boolean
Try
Console.WriteLine("Try Block")
If isEx Then
Throw New Exception("Throw Error")
End If
Func = True
Catch ex As Exception
Console.WriteLine("Catch Block:" + ex.Message)
Func = False
Finally
Console.WriteLine("Finally Block")
End Try
Console.WriteLine("This line of code will not be run")
End Function
Public Sub Main()
Console.WriteLine(Func(True))
Console.WriteLine()
Console.WriteLine(Func(False))
End Sub
End Module

If you did not use the return statement, then the code below will be
executed.
Console.WriteLine("This line of code will not be run")

I have added an comment at the end of the code, Console.WriteLine("This
line of code will not be run") will be executed.

I am sorry if I did not change the text in the writeline.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi Woody

Did my suggestion help you?
If you have any concern on this issue,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top