Comments and White Spaces in Visual Basic 2010

What are Comments?

Comments are descriptive lines that you write between the lines of codes, in order to remember what the lines of code do. It is not a part of the code you have written. Using comments are very popular and necessary. In small and basic programs mostly very few comment lines are used, but in relatively complex and long programs the programmers use many lines of comments to keep in mind the functionality of the codes that they have already written. It is a good practice to use comments in your code. It is also helpful for other people to understand the lines of code you have written.

How can we type comments in Visual Basic?

The general syntax is:

You only need to put a single quotation mark to type a comment.

For Example:
In the “Hello CodeJow Viewers!” program we can put comments like;

CommentsSee Also: [button link=”” size=”default” icon=”fa-search-plus” side=”left” target=”” color=”3116b7″ textcolor=”ffffff”]Starting With Visual Basic[/button]

It is important to note that the comments are only instructions and description of the code for the user and they won’t affect the program itself. Comments are always ignored by the compilers.



Moreover; you can insert multi line comments in your program. You only need to put the single quotation mark (‘) and then type your comment for each single line.

It is also possible to insert comments on the lines of codes. Like;

Comments 1

Visual Basic also has a built-in toolbar option that can comment out a line or lines of code automatically. It is also capable of uncommenting a line or lines. Check out below;

Comments Toolbar Option

The shortcut key for commenting a line of code is “Ctrl + K” and then “Ctrl + C

The shortcut key for uncommenting a comment line is “Ctrl + K“ and then “Ctrl + U

Complete Program With The Comments

See Also: [button link=”” size=”default” icon=”fa-th-large” side=”left” target=”” color=”07b713″ textcolor=”ffffff”]Your First Ever Program in Visual Basic[/button]

White Spaces in the code

White Spaces between the lines of codes do not affect the program at all. You can add as much white space as you want and your program still runs the same.


White Spaces