Siebel VB Language Reference > VB Language Reference >
Null Function
This standard VB function sets a variant variable to the Null value. Syntax
Null
Returns
A variant value set to NULL. Usage
Null is used to set a variant variable to the Null value explicitly, as follows: variableName = Null
Note that variants are initialized by Basic to the empty value, which is different from the Null value. 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 Sub
Related Topics
IsEmpty Function IsNull Function VarType Function
|