If Len(NULL) = 0 Then

# Thread: If Len(NULL) = 0 Then

1. Junior Member
Join Date
Dec 1969
Posts
16

## If Len(NULL) = 0 Then

as the title says, I have an If - broblem :)<BR><BR>How can I compare NULL -value? Can I simply write: If NULLvar = NULL Then etc?<BR><BR>I have variable (as array) that is null, I need to know the proper If statement, so that I can move to next variable.<BR><BR>If you know good tutorials or articles about NULL values, please post those here, as I like to experiment my self too. thx...

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## If isNull(expression) Then <eom>

.

3. Senior Member
Join Date
Dec 1969
Posts
1,424

## Refer the IsNull function [eop /]

.

4. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## But, I prefer to do..

.<BR><BR>If Trim(Null & "") = "" Then<BR><BR>To handle zero-length strings, strings of all spaces AND null values all at once.

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Len(NULL) = Null NOT 0

you will have to use ISNULL<BR><BR><BR>the RIGHT way to handle Nulls and enpty values will be<BR><BR><BR>if len(Null & "") = 0 then<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yep...I've been teaching that...

7. Senior Member
Join Date
Dec 1969
Posts
1,424

## I think I used to write that way

before I started doing heaps of .NET development... now I&#039;m a lot more concious of Types and it has had a great effect on my coding style to the extent that I&#039;d be more likely to use the isnull function than to just concatenate the two values.<BR><BR>Yeh, yeh... I know that it doesn&#039;t matter one iota in VBS world, but it&#039;s still in my mind!

8. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Tell me again

why you would trim a Null<BR><BR><BR>

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## In a typed system...

...like VB.NET, you *can&#039;t* just concatenate any old thing with "". At a minimum, you&#039;d probably have to do <BR> If "" & foo.toString() = "" Then<BR>and for all I know, foo.toString() might barf it foo is null.<BR><BR>So I 100% agree with you.<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## He doesn't trim a null...

He trims that concatenation of "" and a variable (or expression) that might be any of several things.<BR><BR>And as he said, he does it to handle &#060;QUOTE&#062; strings of all spaces &#060;/QUOTE&#062;.<BR><BR>Meaning, for example, that the user just typed a bunch of spaces into a form field and submitted that. <BR><BR>

#### Posting Permissions

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