Language Statements and Control Structures in VBScript


Control statements are generally the most used. Thus control statements are listed in detail and all other statements are listed at the end of this document for referral elsewhere.

Conditional Statements

The If Statement

If condition Then statements ...

If condition Then
	statements ...
End If

If condition Then
	statements ...
Else
	statements ...
End If

If condition Then
	statements ...
ElseIf condition Then 
	statements ...
Else
	statements ...
End If

The Case Statement

Select Case expression
	Case first case
		statements ...
	Case other cases ...
Case Else
	statements ...
End Select

Loops

The Until Loop

This loop will execute atleast once.

Do
	statements ...
Until condition

This loop may never execute.

Do Until condition
	statements ...
Loop

The While Loop

This loop will execute atleast once.

Do
	statements ...
While condition

This loop may never execute.

Do While condition
	statements ...
Loop

The While-Wend Loop

While
	statements ...
Wend

The For Loop

In the For loop below the step value can be positive or negative. The step value has a default value of 1.

For counter = start value To end value [Step] step value
	statements ...
	Exit For
	statements ...
Next

All VBScript Statements