Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Website Giveaway Winner Program
#1
Hey guys! I just finished up the application that will determine the winner of my website giveaway. I tried to make it as random as possible. The program also automatically deletes those pesky cheaters from entering...

Here's the code:
[code2=vbnet]Module Module1
Private randomCounterOne As Integer
Private randomCounterTwo As Integer

Sub Main()
Dim YouTubeComments As New List(Of String)
Dim BPForumsComments As New List(Of String)
Dim TotalComments As New List(Of String)

Console.WriteLine("Welcome to the Website Giveaway 2012. We will select 2 winners. Press ENTER to continue")
Console.ReadLine()
Console.WriteLine("To begin, please insert Random Counter One (1-500)")
randomCounterOne = CInt(Console.ReadLine())
Console.WriteLine("To begin, please insert Random Counter Two (1-314,159)")
randomCounterTwo = CInt(Console.ReadLine())


Console.WriteLine("Thanks! Now please press enter to continue")
Console.ReadLine()
Console.WriteLine("Please wait while we populate the list of YouTube commenters")
Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/WGYT.txt")
Dim readEntries As String = reader.ReadToEnd
reader.Close()

For Each entry As String In readEntries.Split(vbNewLine)
If (entry.Length > 0) Then
entry = entry.Replace(" ", "")
entry = entry.ToUpper
YouTubeComments.Add(entry)
End If
Next
s()
Console.WriteLine("YouTube commenter list succesfully populated!")


Console.WriteLine("Please wait while we populate the list of BPFORUMS commenters")

reader = New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/WGBP.txt")
readEntries = reader.ReadToEnd
reader.Close()

For Each entry As String In readEntries.Split(vbNewLine)
If (entry.Length > 0) Then
entry = entry.Replace(" ", "")
entry = entry.ToUpper
BPForumsComments.Add(entry)
End If
Next
s()
Console.WriteLine("BPFORUMS commenters have been populated. Determining and deleting cheaters")

Dim cheaters As New List(Of String)

s()
YouTubeComments.Sort()
For i As Integer = 1 To (YouTubeComments.Count - 1) Step 1
If (YouTubeComments.Item(i).Equals(YouTubeComments.Item(i - 1))) Then
cheaters.Add(YouTubeComments.Item(i - 1))
End If
Next

BPForumsComments.Sort()
For i As Integer = 1 To (BPForumsComments.Count - 1) Step 1
If (BPForumsComments.Item(i).Equals(BPForumsComments.Item(i - 1))) Then

cheaters.Add(BPForumsComments.Item(i - 1))
End If
Next

For Each cheater As String In cheaters
While (YouTubeComments.Contains(cheater))
YouTubeComments.Remove(cheater)
End While
While (BPForumsComments.Contains(cheater))
BPForumsComments.Remove(cheater)
End While
Next

'----
s()

Console.WriteLine("Cheaters purged. Combining lists")
TotalComments.AddRange(YouTubeComments.ToArray)
TotalComments.AddRange(BPForumsComments.ToArray)
s()

Console.WriteLine("Lists combined - Picking random winner # 1 & 2")
Dim rndIndex As Integer
For lol As Integer = 1 To randomCounterOne Step 1
rndIndex = CInt((Int(Rnd() * TotalComments.Count)))
Next

Dim secondRndIndex As Integer = rndIndex
For lol As Integer = 1 To randomCounterTwo Step 1
While (rndIndex = secondRndIndex)
secondRndIndex = CInt(Int((Rnd() * TotalComments.Count)))
End While
Next
s()

Console.WriteLine("Winner Indices determined! Drumroll please..")
s()
Console.WriteLine("3...")
s()
Console.WriteLine("2...")
s()
Console.WriteLine("1...")
s()
Dim gColor As ConsoleColor = Console.ForegroundColor
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("The first winner is: " & TotalComments.Item(rndIndex).ToString & " Congratulations!")
Console.ForegroundColor = gColor
s()
Console.WriteLine("Second winner is loading...")
Console.WriteLine("3...")
s()
Console.WriteLine("2...")
s()
Console.WriteLine("1...")
s()
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("The second winner is: " & TotalComments.Item(secondRndIndex).ToString & " Congratulations!")
Console.ReadLine()

End Sub

Public Sub s()
Threading.Thread.Sleep(1500)
End Sub

End Module[/code2]

P.S: I know this is not the best way to do this. Time was of the essence.

Here are the two files you'll need:
[attachment=0]<!-- ia0 -->txtFiles.zip<!-- ia0 -->[/attachment]


Attached Files
.zip   txtFiles.zip (Size: 1.88 KB / Downloads: 1,916)
My Blog | My Setup | My Videos | Have a wonderful day.
#2
This seems like the best way to choose a winner. But, could you make it if winner doesn't respond to you in a week, you choose another one? I think that would be the best. Anyway, I found an error:
[code2=vbnet]' File has not been found.
Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/WGYT.txt")[/code2]
Maybe there is a file in your project, but you should either make the project downloadable, or just that file.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#3
so who is the winner
Support me by take tour to BPForums http://bit.ly/YTBCS1

Get More Views on youtubehttp://addm.cc/?WIZ01V
#4
Vinwarez Wrote:Maybe there is a file in your project, but you should either make the project downloadable, or just that file.
Good point. When the giveaway is over, I'll include all of the files and resources of the project in this thread. Keep an eye out.
My Blog | My Setup | My Videos | Have a wonderful day.
#5
Okay. I thought we should run this code, post who was the winner on our consoles, post it and then the most chosen person wins etc. I was wrong, was I? xD
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#6
Haha, well I was simply planning on running this code to determine the winner. If you would like to simulate the giveaway on your own accord, feel free to do so once the files are released!
My Blog | My Setup | My Videos | Have a wonderful day.
#7
Since the official results video was released, the files are now available for download!
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Program That will Help School jonaskie231 1 11,156 04-06-2014, 11:43 AM
Last Post: brandonio21
  Help needed to recreate a vb6 program into vb2010 icedemonzz 1 11,142 12-17-2013, 06:00 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)