Invalid use of NULL

What’s wrong here.I am trying to determine if a value is in an array.

Have DIM MLNdx as Variant

Then

MLNdx = ArrayGetIndex(MLList, doc.nUnit(0)))

If IsNull(MLNdx) goto Skipit

Contstantly fails when MLNdx is in array

Also tried

If MLNdx = NULL

If MLNdx < 0

If TypeData(MLNdx) = 3

All show error message on console of Invalid use of Null

Also tried Dim MLNdx as Long with same results

Thanks in advance…

ddubos@virtualcon.com

Subject: More info

What I have is a group in the NAB with a list of special units.In the initialize section, I place the members of group in MLList. I have 41 entries there confirmed.

As I process a larger list of units, I need to handle these special ones differently than the rest. So, I want to check the MLList to see if doc.nUnit(0) is contained in it.So I use

ArrayGetIndex(MLList, nUnit(0)). The first one on the list is the first member of MLList or (0). So, a check on the value of MLNdx just before the stmt shows it to have a value of 0.

The next stmt to check MLNdx stops running and displays the error message, invalid use of NULL.

Thanks,

Subject: RE: More info

As Esther stated, use IsNull() to see if you did not find the element.

Another apprach is to use a List variable.

e.g.

Dim nUnits List as Boolean '-Type doesn’t matter

'-Populate list

nUnits(“Spam”) = True

nUnits(“Ham”) = True

'-Process if not in list

newVar = “Jam”

if Not isElement(nUnits(newVar)) then

'-Do stuff

end if

Subject: I think I got it now

Esther said to check the array. I was using error checking and a debug log. When I created the list, i had it dim ed as a variant and then gave it the value of group.members. I used a loop instead, dim it as a string and redimed it in the loop and that seemed to make the array work.

Thanks to all for your help. I have been working on this one line for a day.

Subject: Invalid use of NULL

try IsEmpty(MLNdx)

Subject: RE: Invalid use of NULL

Or IsArray to check the opposite condition.

Subject: IsEmpty didn’t work either

Subject: Invalid use of NULL

It SHOULD work - I’ve used the following code with no problem:

Dim includeV as variant

includeV = Arraygetindex(noUpdate, v.Name)

If Isnull(includeV) Then

Msgbox "working with " & v.Name

End If

Do you have true error trapping on your code? i.e.

On Error goto Errhandler

–code–

Errhandler:

msgbox "Error at line " & erl & ": " & error

You might find that the error is happening on a different line than you think.

Alternatively, is MLList really an array?