If ... Then...Else

Repeat a block of statements.

      If condition Then [Statements] [Else Else-Statements]
      If condition Then
      [ElseIf condition-n] Then
      End If

   condition   An expression that evaluates to True or False

   Statements  Program code to be executed if condition is True


hournow = hour(Time())
If hournow > 12 Then WScript.Echo "Good Afternoon"

Dim strCountry
strCountry = "USA"

If strCountry = "USA" Then
   WScript.Echo "United States of America."
ElseIf strCountry = "CA" Then
   WScript.Echo "Canada."
   WScript.Echo "Some other country."
End If

“You have to learn the rules of the game. And then you have to play better than anyone else” ~ Albert Einstein


Select...Case - Conditional execution of a block of code
Do..Loop - Repeat a block of statements
While...Wend - Conditionally repeat a block of statements
Equivalent in PowerShell: If

© Copyright SS64.com 1999-2015
Some rights reserved