Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 17 / 68

Writing comments

This lesson covers writing comments in VB.NET, with the aim of making the intent of your code clear to others and to yourself.

' makes the rest of the line a comment with no effect on execution. A comment is an explanation for humans, recording the intent or the reason behind a piece of work.

The sample code shows both a whole-line comment, as in ' This is a single-line comment, and an explanation added at the end of a line, as in Dim price As Integer = 100 ' product price.

A common early stumble is writing so many comments that the code becomes harder to read. A good comment records why rather than what; restating what the code plainly says is unnecessary.

In professional work, comments are an important way of sharing intent across a team. Writing them so that you will still understand in six months makes later changes and handovers far smoother.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)