View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Best/Easiest way to search/find in a string

Norman meant that the dictum is to always explicitly state the method of
comparison within the instr function command rather than depend on any
default/global setting. He used the term text comparision to mean how the
comparison is to be performed (binary or text) rather than that the
vbTextCompare be used as you appeared to interpret his suggestion. Futher
he envisioned this as a guiding principle in general across all functions
where appropriate - an Axiom

--
Regards,
Tom Ogilvy


"Rick Rothstein (MVP - VB)" wrote:

In the case of the Instr method, the message should be:
always explicitly state the text comparison method; then.
any confusion will be avoided.

In fact, why limit this dictum to Instr?


The "text comparison method" may not always be the appropriate one. For
example (and this is a far-fetched example), what if you were looking for
USB (as in USB computer port) in a large piece of text... a case insensitive
search might turn locate the "usb" in "husband" before it finds the USB you
are looking for. Being able to specify a case sensitive search would (well,
at least should) eliminate that possibility. An argument could be made for
making the case insensitive option the default one, but providing the
capability for both is desirable (in my opinion). However, Microsoft has
already fixed the default for InStr (as well as other functions) ages ago,
so there is no point in considering the "what ifs" for them. More important
than which case should be the default, I wish an option for "whole word"
would have been implemented for InStr so that "the" wouldn't be found in
"other" before "the" was found standing alone. But that is another wish that
will go unanswered I'm afraid.

Rick