Author Topic: String - List Comparison  (Read 1673 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
String - List Comparison
« on: May 02, 2008, 12:53:04 PM »
I have been using this to see if a sample string is in the target string
Code: [Select]
InStr(1, UCase(strNames), UCase(TestString), vbTextCompare)

but without realizing it I have a bigger problem now ... sometimes I have similar strings and the return value is true when I expect false .. for example when "ID1" is the test string and "ID10" is already in the string ...

I'd like to have a better method of doing the comparison, but it needs to be efficient.

I'll take any suggestions
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16872
  • Superior Stupidity at its best
Re: String - List Comparison
« Reply #1 on: May 02, 2008, 12:58:20 PM »
nevermind ... I figured it out ..my string is comma delimited so I changed the check to

Code: [Select]
InStr(1, UCase(strNames), UCase(TestString) & ",", vbTextCompare)

The string also always ends with a comma so all is good ..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bob Wahr

  • Guest
Re: String - List Comparison
« Reply #2 on: May 02, 2008, 08:23:56 PM »
I thought ID10 was always followed by a T

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: String - List Comparison
« Reply #3 on: May 02, 2008, 11:22:22 PM »
I thought ID10 was always followed by a T

 :roll:

 :laugh:
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--