Page 1 of 1

Please help with code

Posted: Tue Aug 28, 2012 11:57 pm
by muttley1968
Hello I have built this but need to know a way to add a user to the draw I can add them to the list view with all the info but any how it works
For example, let's pretend I have a 10-slot lottery. I would write the entries as follows:

foxilvery 2 #3
supersilver 3 #1
chimmy 4 #3
toby 1 #4

I use an excel function that would basically do this:

foxilvery 3
foxilvery 3
supersilver 1
supersilver 1
supersilver 1
chimmy 3
chimmy 3
chimmy 3
chimmy 3
toby 4

All those numbers combined = 25. So, I would count along that listbox to #25. In this case, Supersilver's last ticket would win. Second place would belong to Toby.
soo how can I do this in code here is my form

Image

Re: Please help with code

Posted: Wed Aug 29, 2012 1:17 am
by muttley1968
Is no one is able to help can someone atleast point me in the right direction

Re: Please help with code

Posted: Wed Aug 29, 2012 2:44 am
by CodenStuff
I'm not clear on what it is you are trying to do and I'm half asleep but I think I get the idea. Would something like this work?
Code: Select all
        Dim Winner = 0
        For i = 0 To 25
            Winner += 1
            If Winner = ListView1.Items.Count - 1 Then
                Winner = 0
            End If
        Next
        Me.Text = ListView1.Items(Winner).Text

Re: Please help with code

Posted: Wed Aug 29, 2012 6:20 am
by muttley1968
Every time a participant buys tickets, I will write down the participant's name, amount of tickets, and his or her #1-5. This goes on a listview, At the end of the lottery, I will add up all the numbers per ticket. I will use that sum to count along the listbox. The name that number lands on is the first-place winner. For second place, I count along the list using that number again, starting where I left off for the first-place winner.

For example, let's pretend I have a 10-slot lottery. I would write the entries as follows:

foxilvery 2 #3
supersilver 3 #1
chimmy 4 #3
toby 1 #4

soo the listbox I want to make look something like this

foxilvery 3
foxilvery 3
supersilver 1
supersilver 1
supersilver 1
chimmy 3
chimmy 3
chimmy 3
chimmy 3
toby 4

All those numbers combined = 25. So, I would count along that listbox to #25. In this case, Supersilver's last ticket would win.
Hope that makes sense and that someone can help with code to do this :(