I have to compare two lists of numbers to see if there is a match at all, if there is a match I have to award one point, if there is 2, I award two and so on...I have a program and the code to do it but I do not know where to place the code in order to carry out the process and how to display the number of points. Here is the code I was given and the program is attached:
Dim lngRetVal As Long
Dim intWins As Integer
Dim intIndex As Integer
Dim strPrize As String
For intIndex = 0 To lstUser.ListCount - 1
lngRetVal = SendMessageString(lstComp.hwnd, _
LB_FINDSTRING, -1&, _
lstUser.List(intIndex))
' lngRetVal is the ListIndex
If lngRetVal > -1& Then
intWins = intWins + 1
End If
Next
If intWins = 1 Then
strPrize = " prize."
Else
strPrize = " prizes."
End If
MsgBox "There was " & intWins & " match: you have won " & intWins & strPrize
Last edited by jacobite; Dec 12th, 2002 at 01:15 PM.
I can't understand what you want to do, but the code is pretty clear. It uses the sendMessage API call to see if there's a match in the other list. I am not very familiar with this API call although I know what it does But I think there's no way to count number of matching terms using this API. It only shows whether there's a match.
You can do a simple searching routine that's similar to the searching used in insertion sort.