Page 1 of 1

ListView Contains Help

Posted: Thu Aug 23, 2012 6:00 pm
by muttley1968
Well I have a small lotto game I am making right and I need to see if a listview conatios 7 numbers I have it set up like this a user will buy a ticket and get added like This

Image

Then I click the lotto tab and roll and I want it to then populate the 5 Closest people into the winers section but I can not think for the life of me how to do this

Image


Any help would be most aprechated or even a different way to make tickets I could redo it just want to get it done :P

Re: ListView Contains Help

Posted: Fri Aug 24, 2012 1:01 am
by mandai
You could use a couple of For loops to check the listview sub items.
The specific code will depend on how the numbers are displayed.

Re: ListView Contains Help

Posted: Mon Aug 27, 2012 8:05 pm
by muttley1968
Okay I could not figure that out so I made a new system that works tottaly different this time on the amount of tickets a user has
so on this one you simply buy say 10 tickets and give me a nmber between 1 and 5 I then add um all the numbers
soo say I had 5 entreis with 10 tickest like this

user 10 tickets 5
user 10 tickets 5
user 10 tickets 5
user 10 tickets 5

I would I would add there name into the listbox 10 time for each of them and then count through it 20 times and the person it lands on is the winner anyway here is my system does anyone have any ideas on how to do it with code :P


Image

Re: ListView Contains Help

Posted: Tue Sep 04, 2012 9:05 am
by M1z23R
That is lucky pick, without players - those who enter needing to pick numbers. But if you want to do it like you wanted the first time it is easy...

Do a loop as mandai said, i hope you didn't remove the project
Code: Select all

For each lvi as listviewitem in listview1.items
dim numberofcorrect as integer = 0
for each sublvi as listviewsubitem in lvi.subitems
for each drawnnumber as listviewsubitem in listviewDRAWN1.items
if drawnnumber.text = sublvi.text then numberofcorrect +=1
next
next
if numberofcorrect = 5 then 'or 6 not sure how many should be drawn correctly
msgbox("We have a winner "+lvi.text)
end if
next

Something like that