How to Check for a Null Value

I am trying to determine is a value is null using the below code:

       If Not myValue = "" And Not myValue = DBNull Then
                do stuff
       End If

But it errors and tells me that 'DBNull' is a type and cannot be used as an expression.
Can someone let me know the if statement i need to use to see is a value is not "" and not null
Thanks
kiranboiAsked:
Who is Participating?
 
AkhilBMinConnect With a Mentor Commented:
Use:

If Not myvalue Is Nothing AndAlso Not myvalue Is DBNull.Value Then
'It should work.
0
 
MacNuttinCommented:
Is the value in a database then when you "select data from table where value is null"
0
 
dampseyCommented:
if you want if the value is null in a database, then use DBnull.Value

if you want if the value is null in the memory then use nothing

But nothing should be the first check
so:
if myvalue isnot nothing and myValue <> "" then
   do stuff
end if
0
All Courses

From novice to tech pro — start learning today.