Ok, first off my program is working fine i just need help with my next step of my program.

Dim y As Variant
Dim v As Variant
For Each v In myArray
For Each y In strArray
If (Len(v) = Len(y)) Then
        For i = 1 To Len(y)
            If (InStr(v, Format$(Mid$(y, i, 1), ""))) Then
                List1.AddItem "FOUND: " + v
            End If
        Next i
End If
Next y
Next v

ok so im making a brute force program which basically searches a text file of all the possible answers and then from a array of jumbled up words finds words dependent of the characters of the word has all the same characters in the scrambled words.
so for example:
wlciadt - unscrambles to wildcat.
But my problem is that when adding the item to list box it will add "FOUND: wildcat" 7 times to the list box because there is 7 characters found in wlciadt.
Is there a way i can say or possible to do,

if (word in list box is found len("wlciadt") times) then
text1.text = the found word
end if

hope this is explained well enough,

Many Thanks,
Alan

oh forgot to mention that the brute force tool is not bruting anything maliciously, basicly i have been asked by my college to unscramble 10 words in 30 seconds all randomly chosen from a list of 500 words. which are being placed in an array from a text box.

But my problem is that when adding the item to list box it will add "FOUND: wildcat" 7 times to the list box because there is 7 characters found in wlciadt.

First things first

Change this line
List1.AddItem "FOUND: " + v
to
List1.AddItem "FOUND: " & v

and then add one more line after that

Exit For

so that it looks like this

List1.AddItem "FOUND: " + v
Exit For

ok i think you mis understood the point lol but thanks for trying to help (:
the listbox displays alot of words maybe 50 words. im trying to only find 1 word, basicly the word that has repeated 7 times due to the length of the scrambled word is the word im looking for.
and i want some how to find that word by automating looking for the word that has repeated itself depentent on the length of the scrambled word (7 times).

Can you give us an example?? I dont quite understand.. Is there 50 words scrambled and you need to Unscramble and find one word??

It would appear that your problem is that every time your brute force loop finds an item it adds it to the list.

Instead of adding the item to the list in the nested if end if, count the occurences that it are found in that Nested If structure.

Dim intCount as Integer

If ' ........................
     intCount = 0
     
     For ' ......................
            if " .................................
                  intCount = intCount + 1
            End if
      Next
      
      If intCount > 0  then
               List1.Additem ' ...........................
               intCount = 0
      End if

End if
This article has been dead for over six months. Start a new discussion instead.