Need some help with this I have it running but does not do what I need it to do. When you run the program it is suppose to match the numbers and show witch ones in green also display the number of matches everything else seems to work out fine but that.Can anyone tell me what I am doing wrong. I am new to this and could use the help.
Code:
Option Strict On Public Class Form1 Dim decGrandtotal As Decimal Dim dblJackpot As Double Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim Rand As New Random Dim X, Num1, Num2, Num3, Num4, intCount As Integer Do Until intCount = 9 Num1 = 10 + X Num2 = 20 + X Num3 = 30 + X Num4 = 40 + X intCount = cbo1.Items.Count cbo1.Items.Add(Num1) cbo2.Items.Add(Num2) cbo3.Items.Add(Num3) cbo4.Items.Add(Num4) X += 1 dblJackpot = Rand.Next(CInt(100.0), CInt(1000.0)) txtJackpot.Text = dblJackpot.ToString("C") Loop End Sub Private Sub btnDraw_Click(sender As Object, e As EventArgs) Handles btnDraw.Click Dim intMatch, intLotto1, intLotto2, intLotto3, intLotto4 As Integer Dim Rand As New Random Dim decJackpot, decWin As Decimal If cbo1.SelectedIndex = -1 Then MessageBox.Show("Please Select Number") Exit Sub End If If cbo2.SelectedIndex = -1 Then MessageBox.Show("Please Select Number") Exit Sub End If If cbo3.SelectedIndex = -1 Then MessageBox.Show("Please Select Number") Exit Sub End If If cbo4.SelectedIndex = -1 Then MessageBox.Show("Please Select Number") Exit Sub End If intLotto1 = Rand.Next(10, 20) intLotto2 = Rand.Next(20, 30) intLotto3 = Rand.Next(30, 40) intLotto4 = Rand.Next(40, 50) lbl10.Text = intLotto1.ToString lbl20.Text = intLotto2.ToString lbl30.Text = intLotto3.ToString lbl40.Text = intLotto4.ToString If cbo1.SelectedIndex = intLotto1 Then intMatch += 1 lbl10.BackColor = Color.Green End If If cbo2.SelectedIndex = intLotto2 Then intMatch += 1 lbl20.BackColor = Color.Green End If If cbo3.SelectedIndex = intLotto3 Then intMatch += 1 lbl30.BackColor = Color.Green End If If cbo4.SelectedIndex = intLotto4 Then intMatch += 1 lbl40.BackColor = Color.Green End If If intMatch = 0 Then MessageBox.Show("No Matches = $0.00") ElseIf intMatch = 1 Then MessageBox.Show("Matched 1 = $2.00") ElseIf intMatch = 2 Then MessageBox.Show("Matched 2 = $10.00") ElseIf intMatch = 3 Then MessageBox.Show("Matched 3 =" & decJackpot.ToString("C")) ElseIf intMatch = 4 Then MessageBox.Show("Matched 4 =" & txtJackpot.Text) End If If intMatch = 0 Then decWin = 0 MessageBox.Show("0 Matches =" & decWin.ToString("c")) decGrandtotal += decWin End If End Sub Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click cbo1.SelectedIndex = -1 cbo2.SelectedIndex = -1 cbo3.SelectedIndex = -1 cbo4.SelectedIndex = -1 lbl10.Text = Nothing lbl20.Text = Nothing lbl30.Text = Nothing lbl40.Text = Nothing lbl10.BackColor = Color.Gainsboro lbl20.BackColor = Color.Gainsboro lbl30.BackColor = Color.Gainsboro lbl40.BackColor = Color.Gainsboro End Sub Private Sub btnOut_Click(sender As Object, e As EventArgs) Handles btnOut.Click MessageBox.Show("Grand Total Winnings" & decGrandtotal.ToString("C")) Me.Close() End Sub End Class