Checking for Null

liquidspaces

Well-known member
Joined
Nov 19, 2002
Messages
74
Location
Richmond, VA
If SHIP_TO is dbnull, then it crashes on the strCurrent initialization. This is a bit confusing to me, because strCurrent is the variable I need to check for dbNull. I cant check it until I initialize it, but if I dont check it first I dont get the chance to initialize it. Jeesh.

Code:
For i = 1 To objDataSet.Tables("Shipping").Rows.Count
            strCurrent = objDataSet.Tables("Shipping").Rows(i - 1).Item("SHIP_TO")
            LBTo.Items.Add(strCurrent)
        Next

Any suggestions?
 
Code:
If Not IsDBNull(objDataSet.Tables("Shipping").Rows(i - 1).Item("SHIP_TO") Then
    strCurrent = objDataSet.Tables("Shipping").Rows(i - 1).Item("SHIP_TO")
End If
 
Back
Top