|
|
|
Structure
|
Comments
|
|
Choose(index, choice-1[, choice-2 ... [choice-n])
|
Returns a value from a list of choices (specified by the arguments choice-1 through choice-n) based on the value of index. If index is 1, then the value returned by the function will be represented by choice-1; if index is 2, then the value returned will be choice-2; etc.
|
|
Do Events ()
|
Gives the Operating System temporary control so it can process other events. Typically this is used inside loops so that a program doesn't monopolize system resources
|
|
Do Until condition
Program statement(s)
Loop
|
Performs comparison against test condition at the TOP of the loop. Continues to process the loop as long as condition is False. Use when you don't know how many times the program will need to loop.
|
|
Do While condition
Program statement(s)
Loop
|
Performs comparison against test condition at the TOP of the loop. Continues to process the loop as long as condition is True. Use when you don't know how many times the program will need to loop.
|
|
Do . . .
Program statement(s)
Loop Until condition
|
Performs comparison against test condition at the BOTTOM of the loop. Continues to process the loop as long as condition is False. Use when you don't know how many times the program will need to loop.
|
|
Do . . .
Program statement(s)
Loop While condition
|
Performs comparison against test condition at the BOTTOM of the loop. Continues to process the loop as long as condition is True. Use when you don t know how many times the program will need to loop.
|
|
End ...............................................................................
End Function ................................................................
End If ............................................................................
End Property .................................................................
End Select .....................................................................
End Sub .........................................................................
End Type .......................................................................
End With .......................................................................
|
Ends a program
Ends a function
Ends a program block
Ends a procedure
Ends a Select Case program block
Ends a subroutine
Ends a type structure
Ends a With program block
|
|
Exit Do ..........................................................................
Exit For .........................................................................
Exit Function .................................................................
Exit Sub .........................................................................
|
Used to exit a Do Loop early
Used to exit a For Loop early
Used to exit a Function early
Used to exit a Subroutine early
Placed inside a loop, these statements allow the program to exit directly from a loop before the loop naturally finishes. Avoid using these if at all possible.
|
|
For counter-variable=start To end (Step increment)
Program statement(s)
Next
|
Use when you know how many times the program will need to loop.
|
|
For Each element In group
Program statement(s)
Next element
|
This block of code is entered if there's at least one element in the group. When there are no more elements in the group, this block of code is exited and the statement after the Next is executed
|
|
GoSub line
Program statement(s)
line:
Program statement(s)
Return
|
Transfers control to the subroutine indicated by the label or line number lineuntilReturn is reached; then returns control to the line of code immediately following GoSub.
|
|
GoTo line
|
Transfers control to the line of code specified by line. The label or line number specified by line must be inside the procedure containing the GoTo . Use sparingly.
|
|
If condition Then statement
|
|
|
If condition Then
Program statement(s)
ElseIf condition2 Then
Program statement(s)
Else
Program statement(s)
EndIf
|
There can be any number of ElseIf or Else statements. Tedious to read; tedious to understand avoid using this structure if at all possible.
|
|
IIF (condition, TrueBody, FalseBody)
|
Works like a spreadsheet @if function. Example:
curBonus = IIF(curRevenue < 5000.00, 0.00, 75.00) is equivalent to:
If (curRevenue < 5000.00 _
Then
curBonus = 0.00
Else
curBonus = 75.00
EndIf
Avoid using this if at all possible it's just too cryptic to be easily readable.
|
|
On condition GoSub destinationlist
|
Evaluates condition and, depending on its value, transfers program control to a certain subroutine. destinationlist contains one or more comma-delimited line labels or line numbers representing possible subroutines. If condition equals 1, then the first subroutine in the destinationlist is used; if it's 2, then the second subroutine in the destinationlist is used; and so on. When a Return statement is encountered, control is transferred to the line of code immediately following the On...GoSub.
|
|
On condition GoTo destinationlist
|
Evaluates condition and, depending on its value, transfers program control to a certain line label or line number. destinationlist contains one or more comma-delimited line labels or line numbers representing possible transfer points. If condition equals 1, then the first line label in the destinationlist is used; if it's 2, then the second line label in the destinationlist is used; and so on.
|
|
Select Case Index
Case 1 program statement(s)
Case 2 program statement(s)
Case 3 program statement(s)
[Case Else
program statement(s)]
End Select
|
Known as a Select Case structure.
|
|
Select Case Expression
Case is relation
program statement(s)
Case is relation
program statement(s)
Case is relation
program statement(s)
[Case Else
program statement(s)]
End Select
|
Known as an Is Select Case structure.
relation is any test performed against Expression.
|
|
Select Case Expression
Case Expression1 To Expression2
program statement(s)
Case Expression1 To Expression2
program statement(s)
Case Expression1 To Expression2
program statement(s)
[Case Else
program statement(s)]
End Select
|
Known as a To Select Case structure.
Usually used when dealing with ranges of data the expressions represent the starting and ending values for each range.
|
|
InputBox ()
|
Receives text which has been typed into a dialog box by the user (see InputBox Page)
|
|
MsgBox ()
|
Returns one of seven numerical values signifying the following (see MsgBox Page)
|
|
Resume [0]
Resume Next
Resume line
|
Resumes program execution after an error-handling routine finishes. Resume by itself causes execution to resume with the statement that caused the error or, if the error occurred in a called procedure, the statement that last called the error-handling procedure. Resume Next resumes execution with the statement immediately following the one that caused the error. Resume line transfers control to the line label or line number specified by line.
|
|
Stop
|
Suspends program execution; but it doesn't close any files or clear variables unless it's in a compiled program
|
|
Switch(expr-1, value-1[, expr-2, _
value-2 ...[, expr-n, _ value-n]])
|
Evaluates a list of expressions (expr-1, expr-2,...expr-n) and returns a Variant corresponding to the first expression evaluating as True. If expr-1 is True, Switch returns value-1; if expr-2 is True, Switch returns value-2; etc.
|
|
While condition
program statement(s)
Wend
Note: End While instead of Wend under VB.Net
|
Repeats one or more statements while condition remains True. When condition becomes False, control is passed to the line of code immediately following the While...Wend structure.
|
|
With Object
program statement(s)
End With
|
Executes one or more statements on a specified object or user-defined type without having to respecify the name of the object. Once a With block is entered, object cannot change. Nested With blocks are allowed
|