
March 11th, 2013, 08:16 PM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 3
Time spent in forums: 25 m 29 sec
Reputation Power: 0
|
|
|
IF statement calculation ?
Can anybody give me an idea how to fashion an economical IF statement that will provide for single wins $2.00, double wins $10.00, Half the jackpot, and full jackpot wins for the lottery application below? I realize I could produce a very lengthy piece of code that will cover every conceivable combination of winning, but if there's a shorter way I would rather take it instead.
So far, my code is written for single wins (two matches) and the full jackpot (four matches). Double wins, any combination of two matches, and half the jackpot win which is any combination of three matches will take a lengthy IF statement.
I'm new to VB and programming and in bad need of help on this one.
Code:
Dim selectedItem1 = cboOne.SelectedItem.ToString
Dim selectedItem2 = cboTwo.SelectedItem.ToString
Dim selectedItem3 = cboThree.SelectedItem.ToString
Dim selectedItem4 = cboFour.SelectedItem.ToString
If selectedItem1 = lbl10.Text Then
lbl10.BackColor = Color.DarkGreen
MsgBox("Winner of " & FormatCurrency(SingleWin.ToString))
End If
If selectedItem2 = lbl20.Text Then
lbl20.BackColor = Color.DarkGreen
MsgBox("Winner of " & FormatCurrency(SingleWin.ToString))
End If
If selectedItem3 = lbl30.Text Then
lbl30.BackColor = Color.DarkGreen
MsgBox("Winner of " & FormatCurrency(SingleWin.ToString))
End If
If selectedItem4 = lbl40.Text Then
lbl40.BackColor = Color.DarkGreen
MsgBox("Winner of " & FormatCurrency(SingleWin.ToString))
End If
If selectedItem1 = lbl10.Text And selectedItem2 = lbl20.Text And
selectedItem3 = lbl30.Text And selectedItem4 = lbl40.Text Then
lbl10.BackColor = Color.DarkGreen
lbl20.BackColor = Color.DarkGreen
lbl30.BackColor = Color.DarkGreen
lbl40.BackColor = Color.DarkGreen
MsgBox("JackPot!!")
End If
URL
|