How do I test if an object is null again?-VBForums
Results 1 to 3 of 3

Thread: How do I test if an object is null again?

  1. #1

    Thread Starter
    Hyperactive Member capsulecorpjx's Avatar
    Join Date
    May 2005
    Location
    Renton, WA
    Posts
    288

    How do I test if an object is null again?

    I thought IsNull was used to see if an object was never set or set to "nothing" but it doesn't work:

    Code:
    Dim test as node 'Node is a linked list node class
    
    if isnull(test) then
    msgbox "null"
    else
    msgbox "not null"
    endif
    For me, "Not Null" always comes up.

    How can I test if an object is nothing/null/not set?
    "I like to run on treadmills, because at least I know I'm getting nowhere."
    - Me

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: How do I test if an object is null again?

    Code:
    If test Is Nothing Then '-- it was not set
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    Baby Steps a guided tour
    IsDigits() and IsNumber() functions Wichmann-Hill Random() function >> and << functions for VB CopyFileByChunk

  3. #3
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,438

    Re: How do I test if an object is null again?

    Null isn't the "variable hasn't been initialized" value, but rather "this datapoint doesn't exist so ignore it in aggregate SQL calculations."

    To identify whether a variable has been initialized is different for variants and objects:

    If IsEmpty(Variant) Then ' Variant variable was not initialized

    If (Object Is Nothing) Then ' Object variable was not initialized

    There's also IsMissing(), which is used to check if Optional parameters of type Variant were sent.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.