Based on the code below, why does the variable pos keep
coming up to 1 (indicating a match) when there is no
obvious match between the contents of variable 'transit'
and second element contained in myarray?

Function CompareOSDTransitsToOriginator()
dim myArray
OSDTransits = "44444,33333,55555,22222"
transit = "00968"
myArray = Split (OSDTransits,",")
msgbox myArray(1) ' which is "33333"

pos = instr(1, myArray(1), transit, 1)
if pos > "0" then
msgbox("Match found...")
else
msgbox("NO Match...")
end if
msgbox pos

End Function

Re: Instr function by Al

Al
Sun Aug 24 12:31:05 CDT 2003

Without trying it out myself, I would be suspicious of your if statement:

if pos > "0" then


The reason: pos is an integer value and "0" is a string value. At the very
least, this is an ambiguous test. Try changing it to:

if pos > 0 then

and see if that helps.

/Al

"Wil Adler" <wadler63@ican.net> wrote in message
news:046601c368f1$e889d520$a301280a@phx.gbl...
> Based on the code below, why does the variable pos keep
> coming up to 1 (indicating a match) when there is no
> obvious match between the contents of variable 'transit'
> and second element contained in myarray?
>
> Function CompareOSDTransitsToOriginator()
> dim myArray
> OSDTransits = "44444,33333,55555,22222"
> transit = "00968"
> myArray = Split (OSDTransits,",")
> msgbox myArray(1) ' which is "33333"
>
> pos = instr(1, myArray(1), transit, 1)
> if pos > "0" then
> msgbox("Match found...")
> else
> msgbox("NO Match...")
> end if
> msgbox pos
>
> End Function
>