A good way to temporarily remove large slabs of code within a subroutine is to fence it as

if 1 = 2 then

… code to be temporarily switched off

end if

Since 1 will never equal 2, the condition is always false, so execution does not resume until after the ‘end if’.

I prefer this to commenting out code, even to using the VB Express bulk comment/uncomment, which can sometimes take your comments with it.

Another approach to quickly test something, like a DefCon, is to temporarily place the code block at the top of the subroutine, immediately followed by Exit Sub. For example

The DefCon for Income will never be hit until the Exit Sub is removed.

Categories:

Tags:

Comments are closed