Apr 22, 2012 Replies: 3 It would be very handy if we could fold up our code on If Then statements. Thanks... Click to expand...
NJDude Expert Licensed User Longtime User Apr 22, 2012 #2 There's already an IDE feature that does it, check #Region ... #End Region.
rfresh Well-Known Member Licensed User Longtime User Apr 22, 2012 #3 Thanks...That's a help but I wish it was automatic for all of them like it is for subs.
T Troberg Well-Known Member Licensed User Longtime User Feb 27, 2015 #4 Regions are neat, but not for everything. Typical example: Code: If OperationWorked Then 'Process result 'Do lots of stuff Else 'Error handling 'Do some error handling End If In a case like that, I like to hide the error handling when it's done. It's an exception that's not part of the normal program flow, and I don't need to see it when I do the tougher parts in the normal execution path. Also, it's not uncommon to nest several levels of tests like these, all of them having a "tail" that is not used unless something is wrong (say, when testing a bunch of arguments to see if they are valid). It's just trivial code that needs to be there, but I don't want to see it as it obfuscates what I'm realling doing. Having a bunch or regions here would add a lot do "code space overhead", and hardly contribute to the visibility. Having the above code fold to: Code: If OperationWorked Then 'Process result 'Do lots of stuff Else 'Error handling End If would be much better, and once the code is done, folding it to: Code: If OperationWorked Then 'Process result Else 'Error handling End If would give a very clean, readable view of what the code does from a "cloud free altitude".
Regions are neat, but not for everything. Typical example: Code: If OperationWorked Then 'Process result 'Do lots of stuff Else 'Error handling 'Do some error handling End If In a case like that, I like to hide the error handling when it's done. It's an exception that's not part of the normal program flow, and I don't need to see it when I do the tougher parts in the normal execution path. Also, it's not uncommon to nest several levels of tests like these, all of them having a "tail" that is not used unless something is wrong (say, when testing a bunch of arguments to see if they are valid). It's just trivial code that needs to be there, but I don't want to see it as it obfuscates what I'm realling doing. Having a bunch or regions here would add a lot do "code space overhead", and hardly contribute to the visibility. Having the above code fold to: Code: If OperationWorked Then 'Process result 'Do lots of stuff Else 'Error handling End If would be much better, and once the code is done, folding it to: Code: If OperationWorked Then 'Process result Else 'Error handling End If would give a very clean, readable view of what the code does from a "cloud free altitude".