473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

can i go explicitly to FINALLY part ?

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 ?
Nov 20 '05 #1
11 5149

"Daylor" <Da****@012.net.il> wrote in message
news:3f********@news.012.net.il...
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
Nov 20 '05 #2
"Daylor" <Da****@012.net.il> 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

Nov 20 '05 #3
Cor
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
Nov 20 '05 #4
Cor
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

Nov 20 '05 #5
Nak
> 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!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #6
Hello,

"Daylor" <Da****@012.net.il> 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
Nov 20 '05 #7
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" <Da****@012.net.il> wrote in message
news:3f********@news.012.net.il... 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 ?

Nov 20 '05 #8
"Daylor" <Da****@012.net.il> wrote in news:3f********@news.012.net.il:

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
Nov 20 '05 #9

"Nak" <a@a.com> wrote in message
news:uV*************@tk2msftngp13.phx.gbl...
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"
Nov 20 '05 #10
Hello,

"Ed Crowley" <cu******@pacbell.net> schrieb:
Check out point 3...


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


LOL

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #11
Nak
> 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!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raymond Lesher | last post by:
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...
26
by: djw | last post by:
Hi, Folks- I have a question regarding the "proper" use of try: finally:... Consider some code like this: d = Device.open() try: d.someMethodThatCanRaiseError(...) if SomeCondition: raise...
54
by: Stefan Arentz | last post by:
I was just reading through some old articles in the 'Why not develop new language' thread and came across the finally debate. Everytime I mention 'finally' to C++ programmers I get almost...
16
by: Bill | last post by:
Say I have a childThread currently is running a finally block to cleanup external resources. At the same time the main thread calls childThread.Abort(). The question is: when the...
16
by: Chris | last post by:
Hi, regarding exception-handling : why put code in a 'finally' block, and not just after a 'catch'-block --> Example using 'finally ' : try { OpenFile();
6
by: Alfredo | last post by:
Hi, I have question, i debug this code: try 'Some operations catch Response.Redirect("Page 1") finally Response.Redirect("Page 2")
8
by: vvenk | last post by:
Hello: I just wrote my first ASP.Net application. It worked fine on my machine and when I put into production, the ASP.Net process reaches 50% quite fast and then the system does not work...
3
by: Arnaud Diederen | last post by:
Hello, I've been looking in the archives but found no interesting answer to my problem. I was wondering why the following code does not work in IE 5; I'd expect an alert showing 'In finally!',...
13
by: Jon Davis | last post by:
I understand that the finally sub-block will execute regardless of whether try succeeded or not. But so will code that follows try...catch. So then what is the difference between ... try {...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.