473,385 Members | 1,320 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,385 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 1304
"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...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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
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: 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
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.