Re: Comparing two strings

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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/
>
>
>
.



Relevant Pages

  • Re: Comparing two strings
    ... familiar with the word game "Jumble" that can be found in most newspapers, ... > Without more information there's little help we can give you, for instance if the letters have to be in the same sequence but ... > This time all the letters from strText1 appear in strText2 and visa-versa. ... > 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 ...
    (microsoft.public.vb.general.discussion)
  • Re: a string, a string array and character array
    ... with strings, like sorting. ... uppercase letters have different numerical values but the ... or lowercase letters? ... behaviour) that "lowercase and uppercase letters have different numerical ...
    (comp.soft-sys.matlab)
  • Re: Bayesian updating with multiple events.
    ... probabilities 2/5, etc. ... strings are equally likely. ... probabilities of the letters on cards 2 and 3. ... may not always be as informative as seeing the card ... ...
    (sci.math)
  • Re: Whats going on here?
    ... > letters and numbers at the bottom of documents, ... > long strings of letters/numbers, and another program that does just the ... The length of the code is 16 plus twice the length of the plaintext. ...
    (sci.crypt)
  • Re: Whats going on here?
    ... > letters and numbers at the bottom of documents, ... The messages are secret notes to ... > long strings of letters/numbers, and another program that does just the ...
    (sci.crypt)