How formulas relate to functions in Microsoft Visual Basic

Consider the following Basic syntax formula:

Rem A formula that returns a String value
Rem The function Rnd returns a random number
Rem between 0 and 1
If Rnd > 0.9 Then
   formula = "You won!"
Else
   formula = "Sorry, try again."
End If

The above formula returns the text string value "You won!" if the random number returned by Rnd is greater than 0.9 and the text string value "Sorry, try again." otherwise.

The use of the formula variable is similar to writing a function named formula in Visual Basic.

For example, the above formula could be written as a Visual Basic function as follows:

Rem The following code is in Visual Basic
Function formula()
    If Rnd > 0.9 Then
       formula = "You won!"
    Else
       formula = "Sorry, try again."
    End If
End Function


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