Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
IsNull Function
This standard VB function is used to determine whether a variant variable has the Null value.
Syntax
IsNull(expression)
Returns
-1 (TRUE) if a variant expression contains the Null value, 0 (FALSE) otherwise.
Usage
Null variants have no associated data and serve only to represent invalid or ambiguous results. Null is not the same as Empty, which indicates that a variant has not yet been initialized.
Example
This example asks for ten test score values and calculates the average. If any score is negative, the value is set to Null. Then IsNull is used to reduce the total count of scores (originally 10) to just those with positive values before calculating the average.
Sub Button_Click
Dim arrayvar(10)
Dim count as Integer
Dim total as Integer
Dim x as Integer
Dim tscore as Single
count = 10
total = 0
For x = 1 to count
tscore = 88
If tscore<0 then
arrayvar(x) = Null
Else
arrayvar(x) = tscore
total = total + arrayvar(x)
End If
Next x
Do While x <> 0
x = x - 1
If IsNull(arrayvar(x)) = -1 then
count = count-1
End If
Loop
msgtext = "The average (excluding negative values) is: "
msgtext = msgtext & Chr(10) & Format(total/count, "##.##")
End SubSee Also
IsDate Function
IsEmpty Function
IsNumeric Function
VarType Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |