Although it is POSSIBLE to code multiple statements on one line I rarely do that. One of the places that I might is in the Select Case...End Select code structure like...
Code:
Select Case i
Case 1: s = "Hello"
Case 2: s = "Good Bye"
End Select
Check out Tools > Options -- Editor TAB.
I have all the boxes checked, especially
Require Variable Declaration. Also the
Auto Indent. Indenting code is, IMNSHO, essential to generating readable code.
In general here's what I do to generate readable code:
[tt]
1. Make all my declarations at the top of my Module/Procedure, inserting Comments.
2. Code all structures immediately and then go back and "fill in the blanks."
3. Indent all code/structures within a code structure.
[/tt]
So if I'm coding a loop...
...and then go back and "fill in the blanks"...
Code:
For Each rQTY in [tRQ[QTY]]
Next
...where I ought to have a declaration for rQTY as a Range object variable. The same goes for If...Then...Else...End If
...and then go back and "fill in the blanks"...
Code:
If rQTY.Value <= iLIM Then
Else
End If
So my structured code would look like this...
Code:
Sub RQ_Proc
Dim rQTY As Range 'Quantity in RQ table
Dim iQLIM As Integer 'RQ Quantity Limit
For Each rQTY in [tRQ[QTY]]
If rQTY.Value <= iQLIM Then
Else
End If
Next
End Sub
So even without comments, you can clearly see two structures within the procedure structure. I guess you might say that I am somewhat dogmatic about this. Ha!
Skip,
Just traded in my OLD subtlety...
for a NUance!![[tongue] [tongue] [tongue]](/data/assets/smilies/tongue.gif)