Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can treat null value in vb6 ResultSet

Tags:

vb6

I have a return value from the database but I can not filter the null value.

With rs_receita
    Do Until .EOF
        Set noaux2 = xml.createElement("Superavit")
        noaux2.Text = IIf(IsEmpty(!Superavit), "", CStr(!Superavit))
        Call noaux.appendChild(noaux2)
      .MoveNext
    Loop
End With
Set rs_receita = Nothing
like image 907
J.Sperandio Avatar asked Dec 10 '25 20:12

J.Sperandio


1 Answers

Avoid IIf for this scenario. IIf always evaluates both expressions. So when !Superavit is null, this will cause an error.

A single-line If statement, on the other hand, will only evaluate the expression to be executed. Combine that with the IsNull() function to reliably assign a database value to a variable if it's not null:

If IsNull(!Superavit) Then noaux2.Text = "" Else noaux2.Text = CStr(!Superavit)
like image 156
Bond Avatar answered Dec 15 '25 19:12

Bond



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!