Gustav Brock
Gustav at cactus.dk
Thu Jun 25 02:14:23 CDT 2009
Hi Drew This is a splendid example to demonstrate why _not_ to use GoTo. You have to read you simple example several times to get an idea what is may do. But only an idea. The first variant is much easier if you rewrite it properly: Step 1 If Not SomeCondition Then Step 1 End if Step 2 If Not Another Contition Then Step 2 End if Step 3 If Not FinalCondition Then Step 1 Step 2 Step 3 End if Step 4 This you can grasp by reading it once and you don't even need to know what the Step 1-4 are. /gustav >>> DWUTKA at marlow.com 25-06-2009 00:15 >>> I am going to replace 'a bunch of code' with Step X. Which is easier to follow?: Step 1 If SomeCondition Then Step 2 Else Step 1 Step 2 End if If Another Contition Then Step 3 Else Step 2 Step 3 End if If FinalCondition Then Step 4 Else Step 1 Step 2 Step 3 Step 4 End if OR Step1: Step 1 If SomeCondition Then Goto Step1 Step2: Step 2 If Not Another Condition Then Goto Step2 Step3: Step 3 If Not FinalCondition Then Goto Step1 Step4: Step 4 Which is cleaner? The first method could have you repeating code over and over, the second method has the code once, and simple (and what should be well labeled) 'jump points' to make complex 'logic' simpler. Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Wednesday, June 24, 2009 4:47 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Learning .Net -- PHP Instead? What's wrong with Do ... initial code here.... If <condition1> then 'else goto loop ...more code here.... If <condition2> then 'else goto loop ...more code here... End If End if Loop Again, the indentation from the IF...End IF makes the code much easier to follow that a flat sequence with a series of GOTOs hidden throughout. -- Stuart