vendredi 22 juillet 2016

"Else must be preceded by matching if statement" - unclear error

I have the below syntax, and of the 'elseif' statements I keep getting the error that states "'elseif' must be preceded by matching 'if' or 'elseif' statement". I've used this syntax before so I am not sure why this error has come up if anyone can provide some hints. I've looked at other examples, such as breaking up the "then" to a new line, but they don't seem to work.

It doesn't show error when I just put "If..then" statements but I believe I require an "else if" statement for the decision making.

Private Sub btnDeal_Click(sender As Object, e As EventArgs) Handles btnDeal.Click Dim suit As Double Dim cardval As Double Dim num As String Dim house As String

    For i = 0 To 50 Step 2 ' player 1

        suit = Math.Floor(list(i) \ 13)
        cardval = list(i) Mod 13

        If suit = 0 Then house = "Clubs"
        else
        If suit = 1 Then house = "Diamonds"
        elseIf suit = 2 Then house = "Hearts"
        else suit = 3 Then house = "Spades"
        End if

        If cardval = 0 Then num = "Ace"
        If cardval = 1 Then num = "two"
        If cardval = 2 Then num = "three"
        If cardval = 3 Then num = "four"
        If cardval = 4 Then num = "five"
        If cardval = 5 Then num = "six"
        If cardval = 6 Then num = "seven"
        If cardval = 7 Then num = "eight"
        If cardval = 8 Then num = "nine"
        If cardval = 9 Then num = "ten"
        If cardval = 10 Then num = "jack"
        If cardval = 11 Then num = "queen"
        If cardval = 12 Then num = "king"

        ListBox1.Items.Add("num" & " of " & "house")
    Next

End Sub

Aucun commentaire:

Enregistrer un commentaire