|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
error handleI am moving from vb6 to vb2005 I was using: on error go lbl_error: code.. code.. exit sub or function lbl_error: .code code but it vb 2005 we have try.. catch.. finally end try. In your opinion wich is better for performance and code reading ? Daniel im assuming try catch is better. i was always taught to NEVER EVER use "goto"
and always use try catch end try....i dont have any evidence but i do kno that the try catch makes the code so much easier to read -- -iwdu15 "iwdu15" <jmmgoalsteratyahoodotcom> schrieb: Really?> i dont have any evidence but i do kno > that the try catch makes the code so much easier to read \\\ On Error Resume Next Foo() Goo() Boo() /// - versus - \\\ Try Foo() Catch End Try Try Goo() Catch End Try Try Boo() Catch End Try /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
You want to show with your example that for reading the try, catch, finally, end try is better. Or are you somebody who has in his programs really something like this. > \\\ Without any sentence acting on that between those rows?> On Error Resume Next > Foo() > Goo() > Boo() > /// Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:Oa$kwjEgGHA.2032@TK2MSFTNGP02.phx.gbl... > "iwdu15" <jmmgoalsteratyahoodotcom> schrieb: >> i dont have any evidence but i do kno that the try catch makes the code >> so much easier to read > > Really? > > \\\ > On Error Resume Next > Foo() > Goo() > Boo() > /// > > - versus - > > \\\ > Try > Foo() > Catch > End Try > Try > Goo() > Catch > End Try > Try > Boo() > Catch > End Try > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: I wanted to demonstrate that there are some situations in which 'On Error > You want to show with your example that for reading the try, catch, > finally, end try is better. Resume Next' is superior over 'Try...Catch' because it doesn't blow up the code. > Or are you somebody who has in his programs really something like this. It simply depends on the exact case. The problem I am experiencing with >> \\\ >> On Error Resume Next >> Foo() >> Goo() >> Boo() >> /// > > Without any sentence acting on that between those rows? 'Try...Catch' is that it doesn't support resuming without placing every statement in a separate 'Try...Catch' block. My conclusion is that both solutions, 'On Error Resume Next' and 'Try...Catch' should be brought together by allowing 'Try Resume' blocks or similar and allow the 'Resume' command inside the exception handler's 'Catch' block: \\\ Try Call1() Call2() Call3() Catch If ... Then Resume End If End Try /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
>Resume' blocks or similar and allow the 'Resume' command inside the Developers my age have maybe a fobie from the Cobol "Alter" statement and >exception handler's 'Catch' block: > those like that, but we never want anything that looks like that again. Cor Herfried,
You can partially do that today. | \\\ Resume:| Try | Call1() | Call2() Goto Resume| Call3() | Catch | If ... Then | End If Unfortunately you need an explicit label & know which label to goto, which | End Try | /// is why I say *partially* do it today. -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:%23XnCmhLgGHA.4940@TK2MSFTNGP05.phx.gbl... | "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: | > You want to show with your example that for reading the try, catch, | > finally, end try is better. | | I wanted to demonstrate that there are some situations in which 'On Error | Resume Next' is superior over 'Try...Catch' because it doesn't blow up the | code. | | > Or are you somebody who has in his programs really something like this. | >> \\\ | >> On Error Resume Next | >> Foo() | >> Goo() | >> Boo() | >> /// | > | > Without any sentence acting on that between those rows? | | It simply depends on the exact case. The problem I am experiencing with | 'Try...Catch' is that it doesn't support resuming without placing every | statement in a separate 'Try...Catch' block. My conclusion is that both | solutions, 'On Error Resume Next' and 'Try...Catch' should be brought | together by allowing 'Try Resume' blocks or similar and allow the 'Resume' | command inside the exception handler's 'Catch' block: | | \\\ | Try | Call1() | Call2() | Call3() | Catch | If ... Then | Resume | End If | End Try | /// | | -- | M S Herfried K. Wagner | M V P <URL:http://dotnet.mvps.org/> | V B <URL:http://classicvb.org/petition/> |
Wrapper classes
Windows Service using VB.Net automatic startup problem ! preventing default value in vb.net FAST date string conversion ? catch the process terminate from the task manager make a form shared - called from another form - how? Best Suite Documentation playing & re-playing 7 .wav files How To Force Copy One File To Another Resizing |
|||||||||||||||||||||||