Newbie question: function call

W

wachen

I am using a function to do binary search of an array. I got the code
from a refence book. The function is,

dhBinarySearch(varItems as Variant, varSought as Variant) As Long
The return value is -1 if varSought not found or the position of
varSought in the array.

In my sub, I have the following code

Call dhBinarySearch(varItems, varSought)

If dhBinarySearch = -1 then
does something here
else
does something else here
end if

When I tried to run it, an error box pops up that says
Compile error:
Argument not optional

and highlights the word dhBinarySearch in the If statement

Can anyone help?

Thanks

Warren
 
T

Tom Ogilvy

If dhBinarySearch(varItems, varSought) = -1 then
does something here
else
does something else here
end if

would be the way you would use Mr Getz's function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top