Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

check for null in if statement in vb 6

I'm using vb6

I have a sql server stored procedure that returns a column called TestColumn1.
This column of data type integer.

in my vb6 code i'm getting the stored procedure result and putting it in a recordset.

Sometimes it contains numbers and the stored procedure result is like this:

TestColumn1
1
4
5
12

Other types it contains no records and the stored procedure result is just like this:

TestColumn1


Right now i have the if statement below.
If there are results display appropriate message. If there are no results display the other message
   
    ' my recordset
    Set myrs = cmd.Execute

 If Not myrs.EOF Then
        If myrs.Fields(0) Is Nothing Then
            MsgBox "You got no records."
        Else
            MsgBox "You got some records."
        End If
 End If
   


Right It works ok for when my stored procedure returns records.
But i'm not sure how to check for Null values and the syntax for that inside an if statement.

Anyone know the correct way to check for a null value with an if statement in vb6?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maqskywalker
maqskywalker

ASKER

It turns out this is what I was looking for:

        'if the field is not null then do whats inside this if statement
        If Not IsNull(myrs.Fields(0)) Then
       
            MsgBox "This is a test message"
       
        End If