Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2006
    Location
    South Central, KS
    Posts
    81
    Thanks
    2
    Thanked 2 Times in 2 Posts

    isNull(vbNull) <> true Why?

    if i set a variable to vbNull it doesn't turn null... why is this?

    i = 100
    i = vbNull

    i '// 1
    isNull(vbNull) '// false

    am i missing something?

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by voxecho
    if i set a variable to vbNull it doesn't turn null... why is this?

    i = 100
    i = vbNull

    i '// 1
    isNull(vbNull) '// false

    am i missing something?
    VBNull is a constant and should only be used with the VarType function.
    When you do this:
    i = vbNull you are assigning a 1 to i.
    So:
    isNull(i) would be false as well as isNull(vbNull) because vbNull is a constant = 1.

    If you are having trouble grasping my explanation just google "vbnull" or "vbnull vbscript" and you will find many explanations.

    BaldEagle

  • #3
    New Coder
    Join Date
    Jan 2006
    Location
    South Central, KS
    Posts
    81
    Thanks
    2
    Thanked 2 Times in 2 Posts
    yes, i gathered all that. though it doesn't make sense to me to have it only for comparison. ah well.

    how CAN you set a variable to null?

  • #4
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The only time I can think of it having a null would be when pulling data from a db with an empty field (never had data in it). You can set a var to Empty but IsNull will still return a false, however IsEmpty will return true.

    myVar = Empty

    Is there some particular reason you want Nulls?

    BaldEagle

  • #5
    New Coder
    Join Date
    Jan 2006
    Location
    South Central, KS
    Posts
    81
    Thanks
    2
    Thanked 2 Times in 2 Posts
    thanks, that's the result i needed

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can also use Null

    Code:
    <%
    myvar = Null
    
    If IsNull(myvar) Then
    	Response.Write "myvar is null"
    End If
    %>

  • #7
    New Coder
    Join Date
    Jan 2006
    Location
    South Central, KS
    Posts
    81
    Thanks
    2
    Thanked 2 Times in 2 Posts
    good BOG man! that's Brilliant!

    hmmm, i thought i had tried that :\ color me sheepish

    thanks

    Quote Originally Posted by degsy
    You can also use Null

    Code:
    <%
    myvar = Null
    
    If IsNull(myvar) Then
    	Response.Write "myvar is null"
    End If
    %>

  • #8
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Degsy. I knew about empty but not null.

    BaldEagle


  •  

    Posting Permissions

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