JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Commenting Your Code

In general, you should add comments to your code when you can to make what's going on clearer. Comments in Visual Basic start with an apostrophe (') and make Visual Basic ignore whatever follows the apostrophe on the line. Here's an example in which I'm adding comments to code to make the code easier to read:

Module Module1
    Sub Main()
        'Declare the variables we will use
        Dim intGrade1, intGrade2, intGrade3, NumberStudents As Integer
        'Fill the variables with data
        intGrade1 = 60
        intGrade2 = 70
        intGrade3 = 80
        NumberStudents = 3      'Three students
        'Display the average value
        System.Console.WriteLine("Average grade = " & _
        Str((intGrade1 + intGrade2 + intGrade3) / NumberStudents))
    End Sub
End Module

The Edit toolbar has a button that will automatically comment out any lines of code that are selected when you click it. And here's a little-known Visual Basic fact left over from Visual Basic's early days: instead of an apostrophe, you can use the term REM in your code to create a comment.

Related Solution:

Found on page:

Commenting Your Procedures


Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor