d is declared as a string and I want to check and see if it's null. IsNull is giving me an error, is there a function in .NET to check if a string is null?
VB Code:
If UCase(objDR("JOB_REQD_OPT_SP")) = "Y" And (IsNull(d) Or Trim(d) = "") Then
Printable View
d is declared as a string and I want to check and see if it's null. IsNull is giving me an error, is there a function in .NET to check if a string is null?
VB Code:
If UCase(objDR("JOB_REQD_OPT_SP")) = "Y" And (IsNull(d) Or Trim(d) = "") Then
checking whether the string 'is nothing' should do the trick.
CheersCode:
dim myNullString as string
if myNullString is nothing then
'do something or not
end if
whats the difference between:
VB Code:
IsNull(mystring) IsNothing(mystring) mystring = ""
isNull is a check for variants ( i think!) dunno if vb.net still uses this
in vb.net strings are taken from the object hirearchy, therefore you can check it's current state by running Is Nothing (not IsNothing) against it.
the use of nulls is not really part of the VB syntax like in Java or C++ etc.
mystring = "" is not truly null. It's just a zero length string...
you can use isnull for checking database fields that are returned to a dataset or something to check that they hold a value.
You can use System.DBnull object as well .