Link to home
Create AccountLog in
Avatar of rp
rpFlag for Portugal

asked on

Vb.Net 2010 null values IsDBNull

When need test if a value is null, my code is something like this:

      If IsDBNull(TbReg.Rows.Item(0)("saldo")) Then
            ChkConsDocSaldadosTes.Checked = False
            Else
                If TbReg.Rows.Item(0)("saldo") = True Then
                     ChkConsDocSaldadosTes.Checked = True
                Else
                    ChkConsDocSaldadosTes.Checked = False
                End If
        End If
Is possible do the same thing with less lines of code.
SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
How about 1:
ChkConsDocSaldadosTes.Checked = ((Not IsDBNull(TbReg.Rows.Item(0)("saldo"))) AndAlso TbReg.Rows.Item(0)("saldo"))

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account