Results 1 to 3 of 3

Thread: Check a null reference

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242

    Check a null reference

    I'm sure this one is easy...

    How do I check if an object contains a Null reference?

    Thanks in advance
    Live your own life, for you will die your own death.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    easy indeed... with Is Nothing
    Live your own life, for you will die your own death.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    You might want to take note that IsNull and IsEmpty from VB6 have been declared obsolete in VB.Net. You can now use IsDBNull() which takes an object as a parameter and returns a boolean value indicating wether the variable has been initialized.


    You can also work with the DBNull class which is part of the System namespace. Ill give you examples of bolth methods for comparison puposes.

    Code:
    Dim sysNull as System.DBNull
    Dim strString as String
    
    If strString is sysNull Then 
      strString = " String is now initialized"
    End If
    
    If Not IsDBNull(sysString) Then 
      Debug.WriteLine strString
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width