View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default InStr GRRRRRRRR!!!!!!!!

Option Base has no effect on the index number used to refer to the first
element of a string - a string is not an array of characters like in C/C++

the first element of a string is always 1.

so yes, your command should be

If InStr(1, inputline3, fred, vbTextCompare) 0 Then

regardless of your Option Base setting.

--
Regards,
Tom Ogilvy

"andy_brit" wrote
in message ...



Who forgot about 'option base 1' at the top of the module and who was
using 0 as the start position for the array comparison.

Somedays, my stupidity astounds even me!

The general help thing is that if you are using an index in a function
is to ensure that the appropriate option statement is used at the top
of the module. My InStr was wayyyyy down the code, completely forgot
about Option...

Thanks for looking anyway

Andy


--
andy_brit
------------------------------------------------------------------------
andy_brit's Profile:

http://www.excelforum.com/member.php...o&userid=28002
View this thread: http://www.excelforum.com/showthread...hreadid=475054