Difference between revisions of "VB syntax"

From mi-linux
Jump to navigationJump to search
 
Line 9: Line 9:
 
Constants are similar to variable, but their value is fixed and cannot be changed 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
+
*There are many different [[VB data types| data types]], each intended to hold certain types of data
*Before you can use a variable you must [[how to declare variables|declare]] it.
+
*Before you can use a variable you must [[VB how to declare variables|declare]] it.
*To store values in variables you must use [[assignment statements]].
+
*To store values in variables you must use [[VB assignment statements|assignment statements]].
  
 
==Calculations==
 
==Calculations==
How to code an equation correctly. Includes [[operator precedence]] rules.
+
How to code an equation correctly. Includes [[VB operator precedence|operator precedence]] rules.
 
  e.g. what is the result of this line of code?
 
  e.g. what is the result of this line of code?
 
       x = 2+3*4-5
 
       x = 2+3*4-5
Line 20: Line 20:
 
==String Operations==
 
==String Operations==
 
Processing text strings. Includes:
 
Processing text strings. Includes:
*[[string concatenation|concatenating strings]]
+
*[[VB string concatenation|concatenating strings]]
*extracting [[sub-strings]] from a string
+
*extracting [[VB sub-strings|sub-strings]] from a string
  
 
==Selection==
 
==Selection==
 
Decision making in VB.  Includes:
 
Decision making in VB.  Includes:
*[[Simple If statement]], If...Then...(Else)...EndIf
+
*[[VB Simple If statement|Simple If statement]], If...Then...(Else)...EndIf
*[[Nested If statements]], If...Then...ElseIf....
+
*[[VB Nested If statements|Nested If statements]], If...Then...ElseIf....
*[[Select Case statement]]
+
*[[VB Select Case statement|Select Case statement]]
  
 
==Looping==  
 
==Looping==  
 
Looping allows us to repeat a section of code many times.  There are two main types of loops:
 
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.
+
*"[[VB For Next|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.
+
*"[[VB While Wend|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.
  
 
==Functions and Subroutines==
 
==Functions and Subroutines==
 
Blocks of code which can be called to perform specific tasks.
 
Blocks of code which can be called to perform specific tasks.
*[[Functions]] return a single result.  e.g. X = Average(2,4)  would put 3 into X.
+
*[[VB Functions|Functions]] return a single result.  e.g. X = Average(2,4)  would put 3 into X.
*[[Subroutines]] do not return a result.
+
*[[VB Subroutines|Subroutines]] do not return a result.
A general description of the use of [[parameters]] applies to both Functions and Subroutines.  
+
A general description of the use of [[VB parameters|parameters]] applies to both Functions and Subroutines.  
  
 
==Arrays and Collections==
 
==Arrays and Collections==
*[[Arrays]] allow us to store a collection of related values under one name.  It becomes easy to process each value in the same way, e.g. to add them all together, to find the largest, etc.
+
*[[VB Arrays|Arrays]] allow us to store a collection of related values under one name.  It becomes easy to process each value in the same way, e.g. to add them all together, to find the largest, etc.
*[[Collections]] are very similar to arrays, but woith many extra, more powerful features.
+
*[[VB Collections|Collections]] are very similar to arrays, but woith many extra, more powerful features.

Latest revision as of 15:33, 13 September 2007

Go back to: Visual Basic.Net resources

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.

Functions and Subroutines

Blocks of code which can be called to perform specific tasks.

  • Functions return a single result. e.g. X = Average(2,4) would put 3 into X.
  • Subroutines do not return a result.

A general description of the use of parameters applies to both Functions and Subroutines.

Arrays and Collections

  • Arrays allow us to store a collection of related values under one name. It becomes easy to process each value in the same way, e.g. to add them all together, to find the largest, etc.
  • Collections are very similar to arrays, but woith many extra, more powerful features.