我有以下代码。使用'elseif'语句之一,我不断收到错误,指出“'elseif'必须先匹配'if'或'elseif'语句”。我之前使用过这种语法,所以如果有人能提供一些提示,我不知道为什么会出现这个错误。我已经看过其他的例子,例如将“then”分解为一个新行,但它们似乎不起作用。
当我只是输入“If..then”语句时,它并没有显示错误,但我相信我需要一个“else if”声明来做出决策。
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"
elseIf 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
答案 0 :(得分:1)
else suit = 3 Then house = "Spades"
可能应该是:
elseIf suit = 3 Then house = "Spades"
-OR -
else house = "Spades"
答案 1 :(得分:0)
您不需要elseIf。您的条件是互相排斥的。在执行这些条件时,function doAnotherAsync() {
return $q(function(resolve, reject){
var globalVar;
doSomeNormalAjaxCall
.then(function(response){
globalVar = response.id;
return doYetAnotherAsync()
.then(function(stripeData){
// some logic
return finalyAsync()
})
})
.then(function(response){
// final processing
})
})
}
不会改变。
suit
答案 2 :(得分:0)
可以使用Select Case Statements,而不需要if语句
Select Case suit
Case 0
House = "Clubs"
Case 1
House = "Diamonds"
Case 2
House = "Hearts"
Case 3
House = "Spades"
End Select
然后你可以为卡片值(cardval)创建另一个Select Case Statement
Select Case cardval
Case 0
num = "Ace"
Case 1
num = "two"
'and so on till all conditions are met