Bookmark and Share

VBScript Comments

Comments are used to leave yourself notes or to mark a piece of code so that it doesn't get executed. In VBScript the comment system is extremely simple because there is only one kind of comment.

Advertise on

VBScript Comment: Single Line Comment

VBScript only has support for single line comments, so commenting out large blocks of code or leaving yourself long notes can be quite a bit of work. The apostrophe is the special character VBScript uses as its comment initiator.

The comment in VBScript works by making the VBScript interpreter ignore everything to the right of the apostrophe until a newline is reached. The following example shows how to leave yourself notes and how you would comment out pieces of code you don't want executed.

VBScript Code:

<script type="text/vbscript">
Dim myMessage
'myMessage = "I am having a great day!"
myMessage = "I could use a nap..."

'This will print out myMessage to the visitor



I could use a nap...

Commenting out segments of code is often quite beneficial when you are trying to debug your VBScript code. Leaving yourself notes in your VBScript is also a good programming practice, as it will remind you of the code's purpose months or even years later when you might be reviewing the code for the first time in a long time.

Bookmark and Share

Found Something Wrong in this Lesson?

Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

Advertise Here

More Tutorials!
Microsoft Office Tutorials Artist Tutorials