Results 1 to 6 of 6

Thread: Comparing Lists *** Resolved ***

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    Edinburgh, Scotland, UK
    Posts
    14

    Comparing Lists *** Resolved ***

    Lo,

    I have two lists, one containing numbers selected by a user between 1 and 49 and the other containing numbers that have been randomly generated that occur over 50 times. I need to somehow comparing them to find a match e.g

    User List
    45
    43
    12

    Comp List
    12
    41
    27
    29
    5

    There was 1 match: you have won 1 prize.

    How would i go about comparing this and displaying the score? Label? Another List? Can anyone help? If so reply or email me at [email protected]
    Last edited by jacobite; Dec 12th, 2002 at 12:45 PM.
    Jacobite

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    VB Code:
    1. lstUser.AddItem 45
    2.     lstUser.AddItem 43
    3.     lstUser.AddItem 12
    4.    
    5.     lstComp.AddItem 12
    6.     lstComp.AddItem 41
    7.     lstComp.AddItem 27
    8.     lstComp.AddItem 29
    9.     lstComp.AddItem 5
    10.    
    11.     Dim lngRetVal As Long
    12.     Dim intWins As Integer
    13.     Dim intIndex As Integer
    14.     Dim strPrize As String
    15.  
    16.     For intIndex = 0 To lstUser.ListCount - 1
    17.         lngRetVal = SendMessageString(lstComp.hwnd, _
    18.                                       LB_FINDSTRING, -1&, _
    19.                                       lstUser.List(intIndex))
    20.         ' lngRetVal is the ListIndex
    21.         If lngRetVal > -1& Then
    22.             intWins = intWins + 1
    23.         End If
    24.     Next
    25.    
    26.     If intWins = 1 Then
    27.         strPrize = " prize."
    28.     Else
    29.         strPrize = " prizes."
    30.     End If
    31.    
    32.     MsgBox "There was " & intWins & " match: you have won " & intWins & strPrize

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    Edinburgh, Scotland, UK
    Posts
    14

    Program

    Heres the program if anyone can slot the above code into it and upload it I would be very greatful as I do not know where to put it.
    Attached Files Attached Files
    Jacobite

  4. #4

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    Edinburgh, Scotland, UK
    Posts
    14

    Thank you

    Cheers Marty
    Jacobite

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Thank you

    Originally posted by jacobite
    Cheers Marty
    you should leave the subject as it was and just add resolved to it.. that way if someone has a similar problem them might come across your post and know from the subject that it is something to look at

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width