Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

04 Syntax


'VB code is written one line at a time,   A line of code is called a statement. (Not all languages
'recognize the end of a line as the end of a statement).

MyString = "hello"

'There are two variations on the rule of one line per statement:
'1. The underline character can be used to allow a long line of code to span multiple physical lines (simply a visual aide)
MyString = "the boys are about" & _
"where we want them"

'2. A colon can be used to put two or more statements on a single line
MyString = "hello" :  YourString = "goodbye"

'VB allows the placement of comments in a line - comments are descriptive text which
'will be ignored during execution of the program.  Comments are usually shown in
'the IDE as green-colored text.  There are two ways to comment code:

'1. start the line with 'REM'
Rem this is a comment line

'2. all code to the right of an apostrophe is treated as a comment
My String = "hello"     'comments go here