Question
Visual Basic/VB.NET Help with application. I need at least two more variables, One Dim and One Const. More can be good but I just need
Visual Basic/VB.NET Help with application. I need at least two more variables, One "Dim" and One "Const". More can be good but I just need one of each. I created a raffle/draw application. Enter 10 names and the application will shuffle the list once and give you a winner from the 10. But i was thinking maybe I should add another feature so i can add the extra "Dim" and "const" variables. I was thinking of a way the application can have two text boxes. One box will be for the user to enter the number of shuffles he wants before the application spits out a winner, the second text box will be the spot number on the list will be the winner. The user enters a number in each text box for example. 5 and 7. The user wants the list to be randomized 5 times and the winner will be who ever lands on spot 7 of the list. Or anything else easier you can think of that can get me the two extra variables. Just rather not get an 80% on my project because I am missing just one more DIM and one more CONST variables. Below is my code and app photos. Please try to keep the code kinda the same. The requirement was an IF Then or Select case or loop statement.
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'Input ListBox1.Items.Add("David") ListBox1.Items.Add("John") ListBox1.Items.Add("Alex") ListBox1.Items.Add("Fernando") ListBox1.Items.Add("Oscar") ListBox1.Items.Add("Angel") ListBox1.Items.Add("Jose") ListBox1.Items.Add("Tom") ListBox1.Items.Add("Robbie") ListBox1.Items.Add("Francesca") End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'Declare Variables Dim generator As New Random Dim randomValue As Integer
'Input
randomValue = generator.Next(0, 10)
Try 'Label2.Text = CStr(ListBox1.Items(randomValue))
If randomValue = 1 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 2 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 3 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 4 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 5 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 6 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 7 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 8 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 9 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If If randomValue = 10 Then Label2.Text = CStr(ListBox1.Items(randomValue)) End If Catch ex As Exception End Try 'Display MessageBox.Show("Winner") Label2.ForeColor = Color.Green End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click ListBox1.Items.Clear() Label2.Text = String.Empty End Sub
End Class
RAFFLE APPLICATION David John Alex Femando Oscar Angel Jose Tom Robbie Francesca Jose Reset Random Winner OK
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started