|
Public Function GetWord(Optional ByVal strWord As String) As iWord
Dim objChar As IChar
Dim objLastChar As IChar
Dim lngPtr As Long
Dim strChar As String * 1
Dim sdDirection As SearchDirection
Dim objFinalWord As iWord
Static sobjWord As iWord
If Len(strWord) Then
sobjWord = New iWord
sobjWord.Text = strWord
strChar = Left$(sobjWord.Text, 1)
For Each objChar In mcolLettersInGrid
If objChar.Char = strChar Then
With objChar
sobjWord.AddLetter.Char, .GridX, .GridY
End With
GetWord <<<<<< what does this do in vb6?
End If
If sobjWord.IsComplete Then
GetWord = sobjWord
sobjWord = Nothing
Exit For
Else
sobjWord.RemoveLetter(objChar.GridX, objChar.GridY)
End If
Next
Else
objLastChar = sobjWord.Letter(intIndex:=sobjWord.FoundCharacters)
strChar = Mid$(sobjWord.Text, sobjWord.FoundCharacters + 1, 1)
For sdDirection = sdUp To sdUpRight
While objChar Is Nothing
objChar = NextLetter(objLastChar.GridX, objLastChar.GridY, sdDirection)
If sdDirection = sdUpRight Then
If objChar Is Nothing Then
sobjWord.RemoveLetter(objLastChar.GridX, objLastChar.GridY)
Exit Function
End If
Else
If objChar Is Nothing Then sdDirection = sdDirection + 1
End If
End While
If objChar.Char = strChar And Not sobjWord.IsLetterUsed(objChar) Then
With objChar
sobjWord.AddLetter.Char, .GridX, .GridY
End With
If Not sobjWord.IsComplete Then
GetWord()
End If
End If
If sobjWord.IsComplete Then Exit Function
If Not sobjWord.IsLetterUsed(objChar) Then
sobjWord.RemoveLetter(objChar.GridX, objChar.GridY)
End If
If sdDirection = sdUpRight Then
sobjWord.RemoveLetter(objLastChar.GridX, objLastChar.GridY)
End If
objChar = Nothing
Next
End If
End Function
|