ListView Contains Help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

ListView Contains Help
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
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: ListView Contains Help
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.
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: ListView Contains Help
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
You do not have the required permissions to view the files attached to this post.
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: ListView Contains Help
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
4 posts Page 1 of 1
Return to “Coding Help & Support”