#### Single-line and multi-line If statements

There are two kinds of If statement, the single-line if statement and the multi-line if statement. Starting on a new line after the first Then turns your If statement into a multi-line If statement. Otherwise it is a single-line If statement. The multi-line If statement always includes an End If whereas the single line If statement does not.

Note: Because of the use of line-continuation characters, single-line If statements do not need to be on a single line. In general, it is preferable to use multi-line If statements since they have a clearer layout. However, for simple situations, the single-line If statement is sometimes used.

    Rem Single-line If example 1
    Rem Same result as multi-line If example 1
    If {Employee.Dept} = "Sales" Then _
       formula = {Employee.Salary} * 0.06 _
    Else _
       formula = {Employee.Salary} * 0.04

Here is an example showing various forms of single-line If statements:

    Rem Single-line If example 2
    Dim per As Number, extra As Boolean
    per = 2 : extra = False
    'An example with no Else clause
    If {Employee.Dept} = "Sales" Then per = 10
    'More than 1 statement in the Then or Else part can
    'be included by separating them with colons
    If {Employee.Dept} = "R&D" Then _
       per = 5 : extra = True _
    Else _
       per = 3

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com