In working on this Anagramming program, I've created a recursive function to search for sub anagrams. It works perfectly with letters but when I enter a "*", things go crazy. I get a few words listed repeatedly (15 or so times on some of them) and not all of the expected words show up.
The "*" should be treated as a wildcard and replaced with "a" through "z". Then each of those 26 possibilites is treated as new word.
I can't find the error. Can you?
Code:Public Sub DoWildCardAnagram(w$) Dim i As Single w$ = SortWord(w$) 'rearranges the letters of w$ into alphabetical order 'so that if there's a "*" present it will be the first 'Character If Left(w$, 1) = "*" Then Dim ln As Integer, t$ ln = Len(w$) 'change * to letters and try again For i = 97 To 122 t$ = Right(w$, ln - 1) & Chr(i) DoWildCardAnagram (t$) Next i Me.Caption = t$ Else Dim v As Double v = GetWordValue(txtAnagram) For i = 1 To WordCount 'go through the list of legal words and see if any of them match my word If v / WordValue(i) = Int(v / WordValue(i)) Then If Len(WordList(i)) < 12 Then AddToLists WordList(i) 'found a good word - add it to the list End If Next i End If End Sub


Reply With Quote