Results 1 to 3 of 3

Thread: test for NULL

  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible to test 'NULL'? For example:

    Function MatchUp(style2search As String) As Variant
    MatchUp = 0
    MatchUp = Switch(style2search = "Heading 1", 1, style2search = "Heading 2", 0.25, _
    style2search = "Heading 3", 0.12, style2search = "Heading 4", 0.12)
    End Function

    Sub testmatchup()
    Dim matchret As Variant

    matchret = MatchUp("abc")
    If matchret = "" Or matchret = Null Then ' THIS TEST NEVER WORKS ??????
    matchret = 0
    End If
    End Sub
    Attached Images Attached Images
    Thanks.
    Robie

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    To test whether a variable is Null, use the IsNull function:

    If matchret = "" Or IsNull(matchret) Then

    You can't use

    If matchret = "" Or matchret = Null Then

    because Null is not really a value, it signifies the absence of a value.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='779138' date='10-Jun-2009 17:24']To test whether a variable is Null, use the IsNull function:

    If matchret = "" Or IsNull(matchret) Then

    You can't use

    If matchret = "" Or matchret = Null Then

    because Null is not really a value, it signifies the absence of a value.[/quote]

    Thanks Hans.

    So simple if you know how.
    Thanks.
    Robie

Posting Permissions

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