Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel VB Language Reference > Siebel VB Language Reference >
If...Then...Else Statement
This standard VB control structure executes alternative blocks of program code based on one or more expressions.
Syntax A
If condition Then then_statement [ Else else_statement ]
Syntax B
If condition Then
statement_block
[ElseIf expression Then
statement_block ]...
[Else
statement_block ]
End If
Returns
Not applicable
Usage
When multiple statements are required in either the Then or Else clause, use the block version (Syntax B) of the If statement.
Example
This example checks the time and the day of the week and returns an appropriate message.
Sub Button_Click
Dim h, m, m2, w
h = hour(now)
If h > 18 then
m = "Good evening, "
Elseif h >12 then
m = "Good afternoon, "
Else
m = "Good morning, "
End If
w = weekday(now)
If w = 1 or w = 7
Then m2 = "the office is closed."
Else m2 = "please hold for company operator."
End If
End SubSee Also
Do...Loop Statement
GoTo Statement
On...GoTo Statement
Select Case Statement
While...Wend Statement
Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel VB Language Reference Published: 18 June 2003 |