VB syntax

From mi-linux
Revision as of 14:54, 13 September 2007 by Cm1949 (talk | contribs)
Jump to navigationJump to search

Visual Basic.Net Program Code N.B. Unless otherwise stated the following should apply to all versions of VB.Net.

Variables and Constants

Variables are used to store data values as the program runs. The values in a variable may change as the program runs.

Constants are similar to variable, but their value is fixed and cannot be changed as the program runs.

  • There are many different data types, each intended to hold certain types of data
  • Before you can use a variable you must declare it.
  • To store values in variables you must use assignment statements.

Calculations

How to code an equation correctly. Includes operator precedence rules.

e.g. what is the result of this line of code?
      x = 2+3*4-5

String Operations

Processing text strings. Includes:

Selection

Decision making in VB. Includes:

Looping

Looping allows us to repeat a section of code many times. There are two main types of loops:

  • "For Next" Loops. Used when we know how many times we want to loop before we start. e.g. loop 3 times.
  • "While Wend" and similar loops. Used when we don't know how many times to loop when we start; keep looping until something happens e.g. loop until no more data is input.