'Else' must be preceded by a matching 'If' or 'ElseIf'

billowillo

New member
Joined
Sep 27, 2008
Messages
2
Programming Experience
Beginner
Im trying to create a simple 'slot machine'

VB.NET:
If lblLeft.Text = 1 And lblMiddle.Text = 1 And lblRight.Text = 1 Then intMoney += 10
        MsgBox("You Have Gotten 10 Dollars!")
        elseIf lblLeft.Text = 2 And lblMiddle.Text = 2 And lblRight.Text = 2 Then intMoney += 20
        MsgBox("You Have Gotten 20 Dollars!")
        elseIf lblLeft.Text = 3 And lblMiddle.Text = 3 And lblRight.Text = 3 Then intMoney += 30
        MsgBox("You Have Gotten 30 Dollars!")
        elseIf lblLeft.Text = 4 And lblMiddle.Text = 4 And lblRight.Text = 4 Then intMoney += 40
        MsgBox("You Have Gotten 40 Dollars!")
        elseIf lblLeft.Text = 5 And lblMiddle.Text = 5 And lblRight.Text = 5 Then intMoney += 50
        MsgBox("You Have Gotten 50 Dollars!")
        elseIf lblLeft.Text = 6 And lblMiddle.Text = 6 And lblRight.Text = 6 Then intMoney += 60
        MsgBox("You Have Gotten 60 Dollars!")
        elseIf lblLeft.Text = 7 And lblMiddle.Text = 7 And lblRight.Text = 7 Then intMoney += 70
        MsgBox("You Have Gotten 70 Dollars!")
        elseIf lblLeft.Text = 8 And lblMiddle.Text = 8 And lblRight.Text = 8 Then intMoney += 80
        MsgBox("You Have Gotten 80 Dollars!")
        elseIf lblLeft.Text = 1 And lblMiddle.Text = 1 And lblRight.Text = 1 Then intMoney += 90
        MsgBox("You Have Gotten 90 Dollars!")
        else lblLeft.Text = 10 And lblMiddle.Text = 10 And lblRight.Text = 10 Then intMoney += 100
        MsgBox("You Have Gotten 100 Dollars!")
        endif
theres something wrong this this bit of code though, on all things that have to do with ifs it says 'Else' must be preceded by a matching 'If' or 'ElseIf' and im not sure why.
 
Move the 'intMoney += 10' part down to the next line

Or better yet, turn this complex crap into a Select Case
 
VB.NET:
If lblLeft.Text = lblMiddle.Text And lblMiddle.Text = lblRight.Text Then
    money += CInt(lblLeft.Text) * 10
End If
 
Back
Top