Confusing null comparison

1. Senior Member
Join Date
Dec 1969
Posts
6,476

## Confusing null comparison

Have an IF statement <BR><BR>Basically im searching the same array with 2 loops (i & t)<BR>IF strEmem = arrArray(3,t) AND strEopp = arrArray(9,t) AND (arrArray(7,i) = arrArray(7,t)) AND strEreg = arrArray(8,t) THEN <BR><BR><BR>(arrArray(7,i) = arrArray(7,t)) &#039;Contains a True Null Values<BR>&#039;But wont find matches in the if statement.<BR><BR>I tried it without that part in it like this.<BR><BR>IF strEmem = arrArray(3,t) AND strEopp = arrArray(9,t) AND strEreg = arrArray(8,t) THEN<BR><BR>&#039;OK this finds 5 matches...<BR>&#039;Double Check array TypeName<BR>Response.Write TypeName(arrArray(7,i)) & "," & TypeName(arrArray(7,t))<BR><BR>Produces Null,Null<BR><BR>So they are Nulls...<BR>Another thing I tried was to use exact same element<BR><BR>arrArray(7,t) = arrArray(7,t) &#039;&#060;&#060;&#060;same element<BR><BR>IF strEmem = arrArray(3,t) AND strEopp = arrArray(9,t) AND (arrArray(7,t) = arrArray(7,t)) AND strEreg = arrArray(8,t) THEN <BR><BR>Again it will not match...<BR><BR><BR>Is there some majical way to compare null values in an If statement?<BR><BR>There are 3 columns in this array, each column can contain <BR>1 of 2 different text values or a True Null value...<BR>And I need them all to ba able to match in the IF statement.<BR><BR>Im baffled...<BR>Any ideas anyone?<BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Confusing null comparison

One of the most interesting facts of NULL<BR><BR>Null cannot match anything including Null<BR><BR>I am tempted to say it is a vacuum <BR><BR>So solution is to check ISNULL() which actually return a value you can check namely a binary "true/false"<BR><BR>So ISNULL(arrArray(7,t)) = ISNULL(arrArray(7,t))

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

VBScript Reference (left panel of this page) --&#062; Operators --&#062; Comparison Operators <BR><BR>Look at the table.<BR><BR>If *EITHER* operand to a comparison operator is NULL, the result is *NEITHER* true nor false! The result is NULL.<BR><BR>SO if you do<BR> If NULL = anything Then<BR>you are *not* doing<BR> If True Then<BR>*OR* <BR> If False Then<BR>Instead, you are doing <BR> If NULL Then<BR>But since NULL is not TRUE, the IF is not taken.<BR><BR>What&#039;s more fun is that if you tried to do<BR> If Not ( NULL &#060;&#062; anything ) Then<BR>it wouldn&#039;t help. Because <BR> NULL &#060;&#062; anything<BR>evaluates to NULL and then<BR> Not Null<BR>is...ready for this?...NULL!<BR><BR>http://msdn.microsoft.com/library/en-us/script56/html/vsoprnot.asp<BR><BR>The long and the short of it is that as soon as you have a NULL value, all comparison and logical operators stop working. Period.<BR><BR>You might think you could do:<BR> IF Not IsNull( x ) OR x = value Then<BR>but *that* won&#039;t work in VBScript if x really is NULL. Because that converts to<BR> If Not IsNull( null ) OR null = value Then<BR>which converts to ( because null=value is null)<BR> If Not True OR null Then<BR>which converts to<BR> If False OR null Then<BR>which converts to<BR> If null Then<BR><BR>In short, you simply have to handle NULLs completely separately from most everything else. <BR> If IsNull(x) Then<BR> ...<BR> Else <BR> If x = something Then<BR> ...<BR> Else<BR> ...<BR> End If<BR> End If<BR><BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## I find it funny

That this was originally posted nearly 2 hrs ago and he gets two answers within a minute of each other

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

## Great minds run in the same...

...molasses.<BR><BR>

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

## (which is also known as...

...treacle, right?)<BR>

7. Senior Member
Join Date
Dec 1969
Posts
11,247

## Oh a treacle of information

trickle?

8. Senior Member
Join Date
Dec 1969
Posts
11,247

## I'm on the same wavelength

!

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

"Alice in Wonderland" as a kid and wondering what "treacle" was.<BR><BR>Ever since I found out, I keep meaning to toss it into "slow as molasses" [that is, use "slow as treacle"] but I keep forgetting until after the fact.<BR><BR>See, that&#039;s what senility does to you.<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
11,247

## Talking of Alice

You know why the Hatter was mad don&#039;t you?<BR><BR><BR><BR><BR><BR><BR>The term actually derives from an early industrial occupational disease. Felt hats were once very popular in North America and Europe; an example is the top hat. The best sorts were made from beaver fur, but cheaper ones used furs such as rabbit instead.<BR><BR>A complicated set of processes was needed to turn the fur into a finished hat. With the cheaper sorts of fur, an early step was to brush a solution of a mercury compound—usually mercurous nitrate—on to the fur to roughen the fibres and make them mat more easily, a process called carroting because it made the fur turn orange. Beaver fur had natural serrated edges that made this unnecessary, one reason why it was preferred, but the cost and scarcity of beaver meant that other furs had to be used.<BR><BR>Whatever the source of the fur, the fibres were then shaved off the skin and turned into felt; this was later immersed in a boiling acid solution to thicken and harden it. Finishing processes included steaming the hat to shape and ironing it. In all these steps, hatters working in poorly ventilated workshops would breathe in the mercury compounds and accumulate the metal in their bodies.<BR><BR>We now know that mercury is a cumulative poison that causes kidney and brain damage. Physical symptoms include trembling (known at the time as hatter’s shakes), loosening of teeth, loss of co-ordination, and slurred speech; mental ones include irritability, loss of memory, depression, anxiety, and other personality changes. This was called mad hatter syndrome.

#### Posting Permissions

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