PC Review


Reply
Thread Tools Rate Thread

can i go explicitly to FINALLY part ?

 
 
Armin Zingler
Guest
Posts: n/a
 
      3rd Sep 2003
"Daylor" <(E-Mail Removed)> schrieb
> hi.
>
> let say i have this code:
> --------------------------
> try
> if x=10 then y =1
> if x=200 then goto finally
>
> catch
>
> finally
>
> end try
> --------------------------
>
> the question :
> how can i go explicity to finally when x= 200 ?



try
if x=10 then y =1
if x<>200 then
'...
end if
catch

finally

end try


--
Armin

 
Reply With Quote
 
 
 
 
Ed Crowley
Guest
Posts: n/a
 
      3rd Sep 2003

"Daylor" <(E-Mail Removed)> wrote in message
news:3f55c957$(E-Mail Removed)...
> hi.
>
> let say i have this code:
> --------------------------
> try
> if x=10 then y =1
> if x=200 then goto finally
>
> catch
>
> finally
>
> end try
> --------------------------
>
> the question :
> how can i go explicity to finally when x= 200 ?


Oh sweet jesus no!

Goto is evil. Forget it even exists. The code in finally will always be
executed, after the try block if no exceptions occur or after the catch if
an exception is raised.

Put this in the try block:

If x = 200 Then
'Do something
End If

HTH


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      3rd Sep 2003
Try
if x<> 200 then
if x = 10 then y =1
end if
end if
Catch ex as exeption
messagebox.show(e.message)
Finaly
x=200 ' if there was an error or whatever x will be after this
always 200
End Try


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      3rd Sep 2003
I said sh.......
But I think you saw it yourself I always make this mistake
> Try
> if x<> 200 then
> if x = 10 then

y =1
> end if
> end if
> Catch ex as exeption
> messagebox.show(e.message)
> Finaly
> x=200 ' if there was an error or whatever x will be after this
> always 200
> End Try
>
>



 
Reply With Quote
 
Daylor
Guest
Posts: n/a
 
      3rd Sep 2003
hi.

let say i have this code:
--------------------------
try
if x=10 then y =1
if x=200 then goto finally

catch

finally

end try
--------------------------

the question :
how can i go explicity to finally when x= 200 ?


 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      3rd Sep 2003
> Oh sweet jesus no!
>
> Goto is evil. Forget it even exists.


http://www.everything2.com/index.pl?...l%20programmer ;-)

Check out point 3...

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      3rd Sep 2003
Hello,

"Daylor" <(E-Mail Removed)> schrieb:
> let say i have this code:
> --------------------------
> try
> if x=10 then y =1
> if x=200 then goto finally
>
> catch
>
> finally
>
> end try
> --------------------------
>
> the question :
> how can i go explicity to finally when x= 200 ?


The 'Finally' clock will be executed automatically if there is no more code
in the 'Try' block.

\\\
Try
If x = 10 Then
y = 1
ElseIf x <> 200 Then
...
End If
Catch
...
Finally
...
End Try
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      3rd Sep 2003
Daylor,
Considering that the Try Block is always executed when you exit the try
block, whether there is an exception or not.

How would one cause the try block to Exit, so that the finally block would
be executed. ;-)

Have you tried using Exit Try?

> try
> if x=10 then y =1
> if x=200 then Exit Try
>
> catch
>
> finally
>
> end try


Remember that the Finally block is ALWAYS executed when exit the try block,
whether there is an exception or not.

Return & Exit Sub/Function/Property/Do/For/While/Select would all have
worked equally well!

Of course some developers consider Exit Try as equally evil as Goto.

Hope this helps
Jay

"Daylor" <(E-Mail Removed)> wrote in message
news:3f55c957$(E-Mail Removed)...
> hi.
>
> let say i have this code:
> --------------------------
> try
> if x=10 then y =1
> if x=200 then goto finally
>
> catch
>
> finally
>
> end try
> --------------------------
>
> the question :
> how can i go explicity to finally when x= 200 ?
>
>



 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      3rd Sep 2003
"Daylor" <(E-Mail Removed)> wrote in news:3f55c957$(E-Mail Removed):

>
> the question :
> how can i go explicity to finally when x= 200 ?
>
>


I presume that you want to exit the try block if x = 200. You can use Exit
Try. The Finally portion will still be executed:

try
if x = 10 then y = 1
if x = 200 then Exit Try

catch

finally

end try


 
Reply With Quote
 
Ed Crowley
Guest
Posts: n/a
 
      3rd Sep 2003

"Nak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > Oh sweet jesus no!
> >
> > Goto is evil. Forget it even exists.

>
> http://www.everything2.com/index.pl?...l%20programmer ;-)
>
> Check out point 3...


Hehe. I especially like "Real programmers know structured and object
oriented programming are communist plots"


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to inspect the return value in the 'finally' part of a try...catch without using a variable? Polaris431 Microsoft C# .NET 4 3rd Oct 2007 02:36 AM
Medical CDs - [Part 2], [Part 1], [Part 3 = MEDLINE 1986-1998] CDs ola Windows XP Basics 0 18th Aug 2007 08:19 AM
Try...Catch...Finally not firing finally? David Lozzi Microsoft ASP .NET 12 11th May 2007 01:41 AM
Explicitly passing a .value mazzarin Microsoft Excel Programming 2 30th Jun 2006 07:40 PM
try, catch, finally- whats the point of finally? Alan Paulk Microsoft C# .NET 7 11th May 2004 02:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:14 PM.