Re: Comparing two strings
- From: Joseph <Joseph@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jul 2005 09:37:02 -0700
To give you more insight into what I'm trying to accomplish: If you are
familiar with the word game "Jumble" that can be found in most newspapers, I
am trying to build a program that matches the scrambled letters against a
list of words and finds a match.
"Mike D Sutton" wrote:
> > I'd like to know if Visual Basic has a function that compares two strings
> > such as:
> > strText1= "ABC"
> > strText1= "CBA"
> >
> > Returns a True statement because it compares each individual letter from one
> > string and matches it with the same letter in the other string. For instance,
> > both strText1 and strText2 have the letter "A" but not necessarily in the
> > same order, and same thing for each successive letter. Will I will have to
> > write an algorithm to accomplish this and if so any suggestions?
>
> Without more information there's little help we can give you, for instance if the letters have to be in the same sequence but
> reversed then this will perform the (case insensitive) comparison for you:
>
> '***
> Debug.Print StrComp(strText1, StrReverse(strText2), vbTextCompare) = 0
> '***
>
> How about this though:
>
> '***
> strText1 = "ABC"
> strText2 = "BBB"
> '***
>
> All the letters from strText2 appear in strText1
> Or how about:
>
> '***
> strText1 = "ABC"
> strText2 = "AABBCC"
> '***
>
> This time all the letters from strText1 appear in strText2 and visa-versa.
> How about:
>
> '***
> strText1 = "ABC"
> strText2 = "abc"
> '***
>
> Does case matter?
> And what do you want to return from this, simply a Boolean to say that the strings are the same (by however you decide classify
> that), a series of bit-flags identifying whether certain aspects of the string are 'similar' (i.e. SameCharCount=1, SameLetters=2,
> MatchLetters=4, SameCase=8 etc..) or some kind of 'fuzzy' confidence level that the two strings are similar enough?
> If the latter then you'll need to classify exactly what criteria you work off, sub-strings (i.e. "Hello" and "lloHe" would be more
> similar than "eoHll") or just character counts.
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@xxxxxxxx
> WWW: Http://EDais.mvps.org/
>
>
>
.
- Follow-Ups:
- Re: Comparing two strings
- From: Tim Baur
- Re: Comparing two strings
- References:
- Comparing two strings
- From: Joseph
- Re: Comparing two strings
- From: Mike D Sutton
- Comparing two strings
- Prev by Date: Re: Comparing two strings
- Next by Date: Comparing Two strings
- Previous by thread: Re: Comparing two strings
- Next by thread: Re: Comparing two strings
- Index(es):
Relevant Pages
|