Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After an If statement, I indent all subsequent statements one tab until the
End If. However, I'm struggling with where to put the Else statement. I'd like to know what convention other programmers follow. Do you: 1. Indent it with the other statements, even though it might be difficult to find? 2. Keep it in line with the IF statement? 3. Split the difference, and indent it two spaces rather than four? Thanks for your feedback, Fred |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fred,
Most of us would have If condition Then 'do something ElseIF condition 'do something Else 'do something End If Robin Hammond www.enhanceddatasystems.com "Fred Smith" wrote in message ... After an If statement, I indent all subsequent statements one tab until the End If. However, I'm struggling with where to put the Else statement. I'd like to know what convention other programmers follow. Do you: 1. Indent it with the other statements, even though it might be difficult to find? 2. Keep it in line with the IF statement? 3. Split the difference, and indent it two spaces rather than four? Thanks for your feedback, Fred |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fred,
IDEs typically have the ability to understand code syntax. For instance, functions would be highlighted with one color and parameters another. Same goes for indenting. They automatically indent the code between the beginning and end of any conditional statement or loop. If there's an ELSE in the condition, the IDE will keep it inline with the IF. Obviously, all of the syntax highlighting and indenting is only for the benefit of the programmer. It has no affect on the way the code executes. For VBA, some syntax highlighting is done, and there's an AutoIndent CheckBox in the VBA Editor Options (but I've never actually seen any difference with it Checked or unChecked!). Cheers, Lee "Fred Smith" wrote in message ... After an If statement, I indent all subsequent statements one tab until the End If. However, I'm struggling with where to put the Else statement. I'd like to know what convention other programmers follow. Do you: 1. Indent it with the other statements, even though it might be difficult to find? 2. Keep it in line with the IF statement? 3. Split the difference, and indent it two spaces rather than four? Thanks for your feedback, Fred |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "lgbjr" wrote in message ... Fred, IDEs typically have the ability to understand code syntax. For instance, functions would be highlighted with one color and parameters another. Same goes for indenting. They automatically indent the code between the beginning and end of any conditional statement or loop. If there's an ELSE in the condition, the IDE will keep it inline with the IF. Obviously, all of the syntax highlighting and indenting is only for the benefit of the programmer. It has no affect on the way the code executes. VBA doesn't align the Else with the IF automatically it aligns to the previous line. That would be useful. For VBA, some syntax highlighting is done, and there's an AutoIndent CheckBox in the VBA Editor Options (but I've never actually seen any difference with it Checked or unChecked!). Have you tried it? Unchecking it for me ignores any indenting and starts in column 1. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fred,
Like Robin I align the IF ... Else, like so If Condition Then 'do your stuff ElseIf Condition2 Then 'do something else Else If Suib - Condition Then 'do yet more Else 'but only if condition2 is met End If End If Personally, I never use code like so If a = b Then c = d I always use If a = b Then c = d End If as I feel that the former can confuse in a lot of code, you go looking for an EndIf that isn't there. -- HTH RP (remove nothere from the email address if mailing direct) "Fred Smith" wrote in message ... After an If statement, I indent all subsequent statements one tab until the End If. However, I'm struggling with where to put the Else statement. I'd like to know what convention other programmers follow. Do you: 1. Indent it with the other statements, even though it might be difficult to find? 2. Keep it in line with the IF statement? 3. Split the difference, and indent it two spaces rather than four? Thanks for your feedback, Fred |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|