TheSwamp

Code Red => VB(A) => Topic started by: Keith™ on May 02, 2008, 12:53:04 PM

Title: String - List Comparison
Post by: Keith™ 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
Title: Re: String - List Comparison
Post by: Keith™ 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 ..
Title: Re: String - List Comparison
Post by: Bob Wahr on May 02, 2008, 08:23:56 PM
I thought ID10 was always followed by a T
Title: Re: String - List Comparison
Post by: Kerry on May 02, 2008, 11:22:22 PM
I thought ID10 was always followed by a T

 :roll:

 :laugh: