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 VBScript?

If in doubt, review The Documentation

Taken from Rem Statement
As shown in the syntax section, you can use an apostrophe (') instead of the Rem keyword. If the Rem keyword 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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest