BP Forums
Website Giveaway Winner Program - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+---- Thread: Website Giveaway Winner Program (/showthread.php?tid=657)



Website Giveaway Winner Program - brandonio21 - 09-23-2012

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]


Re: Website Giveaway Winner Program - Vinwarez - 09-23-2012

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.


Re: Website Giveaway Winner Program - manishshrestha60 - 09-24-2012

so who is the winner


Re: Website Giveaway Winner Program - brandonio21 - 09-24-2012

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.


Re: Website Giveaway Winner Program - Vinwarez - 09-25-2012

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


Re: Website Giveaway Winner Program - brandonio21 - 09-26-2012

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!


Re: Website Giveaway Winner Program - brandonio21 - 10-23-2012

Since the official results video was released, the files are now available for download!