How Do You Add Comments in a Vbscript
I Have Some Vbscripts I Would Like to Add My Explanation to Within the Code. Is There Some Syntax for Adding a Comment? 4 1 Answer How Do You Comment Code in...
I have some VBScripts I would like to add my explanation to within the code.
Is there some syntax for adding a comment?
1 Answer
How do you comment code in VBScript?
If in doubt, review The Documentation
Taken from Rem Statement
As shown in the syntax section, you can use an apostrophe (') instead of theRemkeyword. If theRemkeyword follows other statements on a line, it must be separated from the statements by a colon. However, when you use an apostrophe, the colon is not required after other statements.
Below is example using both methods
Rem This is a comment
'This is also a comment
Call SomeFunction(SomeValue) : Rem This is an inline comment
Call SomeFunction(SomeValue) 'This is also an inline comment
There is no real reason to use Rem it's just a throw back from BASIC. The apostrophe approach works just as well as it is less intrusive in my opinion but it is entirely user preference.
What about block comments?
VBScript does not support block comments. Each line must start with either Rem or an Apostrophe '.
Useful Links
- Server-side comments: What's the equivalent of <%— --%> in ASP Classic? (Applies to comments in asp-classic which uses vbscript)