I may simply misunderstand the difference between the two: If the only difference between a subroutine and a function is that a function has the option of returning a value while a subroutine does not, then in what situation would you use a subroutine? Why wouldn’t you always use a function?
I may simply misunderstand the difference between the two: If the only difference between
Share
I use Subs when I need a ‘named piece of code’ that does not return any information, but is called only for its side effects. I use Functions when I need a ‘named piece of code’ that returns some information (and (normally) does not have side effects). I’m glad that I can state my intentions in VBScript explicitly.
Added: Why @AutomatedChaos’ proposal (comment) is misguided: