can i go explicitly to FINALLY part ?

  • Thread starter Thread starter Armin Zingler
  • Start date Start date
A

Armin Zingler

Daylor said:
hi.

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

catch

finally

end try


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

finally

end try
 
Daylor said:
hi.

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

catch

finally

end try

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
 
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
 
hi.

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

catch

finally

end try
 
Oh sweet jesus no!
Goto is evil. Forget it even exists.

http://www.everything2.com/index.pl?node=real programmer ;-)

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!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hello,

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

catch

finally

end try

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
 
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 said:
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
 
Hello,

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

LOL

Regards,
Herfried K. Wagner
 
Hehe. I especially like "Real programmers know structured and object
oriented programming are communist plots"

LOL I read a whole online article that said basically that object
orientated programming was crap and that a table based programming was
preferred, I just thought "What a load of bollocks" and sent him an email
saying so :-) OOP rules as far as I'm concerned :-)

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!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Back
Top