473,387 Members | 3,810 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,387 software developers and data experts.

Exiting a Try block

I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

JGD
Nov 21 '05 #1
6 1305
"John Dann" <ne**@prodata.co.uk> schrieb:
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

Yes, that will work. Nevertheless, notice that a 'Finally' block will be
executed even if you jump outside the block.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
"John Dann" <ne**@prodata.co.uk> schrieb:
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

Yes, that will work. Nevertheless, notice that a 'Finally' block will be
executed even if you jump outside the block.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
Do it like this

Try

If True Then

Exit Try

End If

'Never Gets Executed

Catch ex As Exception

Exit Try

'Nor does this

End Try


"John Dann" <ne**@prodata.co.uk> wrote in message
news:j5********************************@4ax.com...
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

JGD

Nov 21 '05 #4
Do it like this

Try

If True Then

Exit Try

End If

'Never Gets Executed

Catch ex As Exception

Exit Try

'Nor does this

End Try


"John Dann" <ne**@prodata.co.uk> wrote in message
news:j5********************************@4ax.com...
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

JGD

Nov 21 '05 #5
ACK

U have to construct your code appropriately really

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
"John Dann" <ne**@prodata.co.uk> schrieb:
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

Yes, that will work. Nevertheless, notice that a 'Finally' block will be
executed even if you jump outside the block.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6
ACK

U have to construct your code appropriately really

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
"John Dann" <ne**@prodata.co.uk> schrieb:
I want to use a block of code as follows:

Function..........
' Preliminary processes that acquire a value for X
Try
Select Case X
Case 1 etc

Case 2 etc

Case Else
Exit Function
End Select
Catch
Etc
End Try
End Function

But I'm not completely sure whether exiting the overall function in
the middle of the Try block is legal/robust. Can anyone reassure me
please?

Yes, that will work. Nevertheless, notice that a 'Finally' block will be
executed even if you jump outside the block.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

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

Similar topics

2
by: Hal Vaughan | last post by:
I have a class that is sometimes called from the command line and sometimes from another class. When the user clicks "Quit" on the panel it opens, if it is running from the command line, it...
39
by: vineoff | last post by:
If I'm having nested loops like: for (...) for (..) for (...) { /* exit here */ } and I need to exit from there ^ . Is it better to use exceptions or goto or some other method?
22
by: L. Westmeier | last post by:
Is there a way to have to exiting point in a void function? I don't want to exit the program but just this function. Any answers appreciated. L. Westmeier
7
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread....
4
by: Microsoft | last post by:
I have a for loops that goes from 1 to 256 I test the number and exception is thrown if there is an error. How do I get the program to stop in the middle of the loop and go to the next...
0
by: John Dann | last post by:
I want to use a block of code as follows: Function.......... ' Preliminary processes that acquire a value for X Try Select Case X Case 1 etc Case 2 etc
1
by: Karl O. Pinc | last post by:
FYI, mostly. But I do have questions as to how to write code that will continue to work in subsequent postgresql versions. See code below. begintest() uses EXIT to exit a BEGIN block from...
3
by: RSH | last post by:
Hi, I have two questions both by a VB programmer that is learning C#... 1) In a VB error trap routine we would commonly trap the error and write it to an error log and then attempt to "Resume...
6
by: Ant | last post by:
Hi all, I'm putting together a simple help module for my applications, using html files stored in the application directory somewhere. Basically it sets up a basic web server, and then uses the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.