473,386 Members | 1,801 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,386 software developers and data experts.

Try..Catch vs On Error ???

Hello everyone.

How is the function below accomplished in vb.net?

*************************
private function test

on error goto here

for i =0 to x
do something
do some more
do last bit
next

exit function

here:
if the error is this then
resume next 'jump back into the for/next loop
endif

end function
*************************
Nov 20 '05 #1
4 999
Jos
Ralph wrote:
Hello everyone.

How is the function below accomplished in vb.net?

*************************
private function test

on error goto here

for i =0 to x
do something
do some more
do last bit
next

exit function

here:
if the error is this then
resume next 'jump back into the for/next loop
endif

end function
*************************


*************************
private function test

for i =0 to x
do some things that can't go wrong
Try
do something that can go wrong
do some more
do last bit
Catch ex As Exception
' you may also use a more particular Exception object
' e.g. OleDbException
handle the error
Finally
clean up
End Try
next

end function
*************************

--

Jos
Nov 20 '05 #2
Thanks for the answer Jos.
Simple and sweet code.
I have to make an appointment at the hair restoration clinic after this one.

"Jos" <jo***************@fastmail.fm> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Ralph wrote:
Hello everyone.

How is the function below accomplished in vb.net?

*************************
private function test

on error goto here

for i =0 to x
do something
do some more
do last bit
next

exit function

here:
if the error is this then
resume next 'jump back into the for/next loop
endif

end function
*************************


*************************
private function test

for i =0 to x
do some things that can't go wrong
Try
do something that can go wrong
do some more
do last bit
Catch ex As Exception
' you may also use a more particular Exception object
' e.g. OleDbException
handle the error
Finally
clean up
End Try
next

end function
*************************

--

Jos

Nov 20 '05 #3
* "Ralph" <Ra***********@theBusStation.net> scripsit:
How is the function below accomplished in vb.net?

*************************
private function test

on error goto here

for i =0 to x
do something
do some more
do last bit
next

exit function

here:
if the error is this then
resume next 'jump back into the for/next loop
endif


You will have to put every statement into a separate 'Try...Catch'
block.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
One will work fine. I'm trying to ignore the "duplicate records being added
to a table error" and catch everything else.

Thanks for the input
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
* "Ralph" <Ra***********@theBusStation.net> scripsit:
How is the function below accomplished in vb.net?

*************************
private function test

on error goto here

for i =0 to x
do something
do some more
do last bit
next

exit function

here:
if the error is this then
resume next 'jump back into the for/next loop
endif


You will have to put every statement into a separate 'Try...Catch'
block.

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

Nov 20 '05 #5

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

Similar topics

11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
7
by: Arjen | last post by:
Hi, I'm doing this: try { try { } catch(Exception ex){ throw;
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
3
by: will | last post by:
Hi all. I've got an question about how to catch an exception. In Page_Load, I place a DataGrid, dg1, into edit mode. This will call the method called GenericGridEvent. GenericGridEvent will call...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
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: 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
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.