|
-
Mar 31st, 2003, 09:57 AM
#1
Thread Starter
Frenzied Member
checking if a string is null
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
-
Mar 31st, 2003, 10:20 AM
#2
Addicted Member
checking whether the string 'is nothing' should do the trick.
Code:
dim myNullString as string
if myNullString is nothing then
'do something or not
end if
Cheers
-
Mar 31st, 2003, 10:23 AM
#3
Thread Starter
Frenzied Member
whats the difference between:
VB Code:
IsNull(mystring)
IsNothing(mystring)
mystring = ""
-
Mar 31st, 2003, 10:33 AM
#4
Addicted Member
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...
Last edited by powdir; Mar 31st, 2003 at 10:49 AM.
-
Mar 31st, 2003, 10:56 AM
#5
Fanatic Member
you can use isnull for checking database fields that are returned to a dataset or something to check that they hold a value.
-
Mar 31st, 2003, 03:52 PM
#6
Sleep mode
You can use System.DBnull object as well .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|