Results 1 to 15 of 15

Thread: IsNull and <>""

  1. #1

    Thread Starter
    Lively Member mattalexx's Avatar
    Join Date
    Mar 2002
    Location
    Gloucester, MA
    Posts
    77

    IsNull and <>""

    Is there a shorter expression that brings the same result as "IsNull(ctrl.Value) Or Len(Trim(ctrl.Value)) = 0"?

    For example:
    Code:
        If IsNull(ctrl.Value) Or Len(Trim(ctrl.Value)) = 0 Then
            str = "nuthin here"
        End If
    
        ' equals
    
        If ???? Then
            str = "nuthin here"
        End If
    Matt(+)

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    What about just
    If Len(Trim(ctrl.value))<1 then
    'nothing here
    End if
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    don't think Trim on Null vlues will work Lord_Rat
    -= a peet post =-

  4. #4

    Thread Starter
    Lively Member mattalexx's Avatar
    Join Date
    Mar 2002
    Location
    Gloucester, MA
    Posts
    77
    That doesn't work for null values

    Len(Trim(Null)) = Null
    Null < 1 = Null '<--type mismatch

  5. #5
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Admittedly, I didn't try it this time.

    Let me give it a whirl.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    mattalexx, I think the way u do it is it...
    -= a peet post =-

  7. #7
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    What kind of control?

    Using a text box, Trim works fine, as in the attached.
    Attached Files Attached Files
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  8. #8

    Thread Starter
    Lively Member mattalexx's Avatar
    Join Date
    Mar 2002
    Location
    Gloucester, MA
    Posts
    77
    I'm running this function for fields in a DAO recordset.

  9. #9
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50
    what about

    If (IsNull(ctrl.Value)) Or (ctrl.Value) = "") Then
    'Nothing is there
    End If


    That'll work if the data is going to be a text or a number
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  10. #10

    Thread Starter
    Lively Member mattalexx's Avatar
    Join Date
    Mar 2002
    Location
    Gloucester, MA
    Posts
    77
    That's essentially the same as what I proposed in the beginning, isn't it?

    Matt(+)

  11. #11
    WALDO
    Guest

    Lightbulb Ah, on a recordset

    VB Code:
    1. If Len(Value & "") = 0 Then
    2.     'Nuthin there
    3. End If
    The definition for Null as it applies to VB is not the same definition for null as it applies to a recordset. IsNull() isn't 100% effective in this case, but the preceeding code hasn't failed me yet.

  12. #12
    Alain
    Guest

    Hey Waldo...

    Waldo: Just for fun, how many times have you answered this one in the furums yet?

  13. #13
    WALDO
    Guest

    Wink

    Ummm, how many posts do I have?

  14. #14

    Thread Starter
    Lively Member mattalexx's Avatar
    Join Date
    Mar 2002
    Location
    Gloucester, MA
    Posts
    77
    I'm sorry, but sometimes the simplest problems are the hardest to find answers to.

    Thank you very much for your help, Waldo, it is much appreciated.

    Matt(+)

  15. #15
    WALDO
    Guest

    Talking Hey, don't be sorry

    I'm just glad I could help.

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