Excel Visual Vasic Block如果没有结束的话

我正在使用Excel电子表格和Visual Basic来devise游戏。 当我尝试编译“块如果没有结束,如果”我有一个错误。 我已经search,让我们find解决这个问题..

请帮忙..

这是我的代码!

Private Sub Attack_Click() Application.Calculate If Range("H2") <= 0 Then MsgBox ("YOU DIED. GAME OVER") Unload Me End If If Range("I2") <= 0 Then MsgBox ("The Monster has died.") MsgBox (" You find : " & Range("K3") & " Gold.") Range("G1") = Range("G1") + Range("K3") Shop.Show End If If TextBox4.Value = "Basic Attack" Then Range("H2") = Range("H2") - Range("E2") Range("I2") = Range("I2") - Range("C2") - Range("H4") TextBox2.Value = Range("H2") TextBox3.Value = Range("H3") TextBox5.Value = Range("I2") TextBox6.Value = Range("I3") TextBox7.Value = Range("H4") TextBox8.Value = Range("H5") Else If TextBox4.Value = "Magic Blast" Then Range("I2") = Range("I2") - Range("I2") - Range("C3") - Range("H5") Range("H2") = Range("H2") - Range("E2") TextBox2.Value = Range("H2") TextBox3.Value = Range("H3") TextBox5.Value = Range("I2") TextBox6.Value = Range("I3") TextBox7.Value = Range("H4") TextBox8.Value = Range("H5") End If If Range("H2") <= 0 Then MsgBox ("YOU DIED. GAME OVER") Unload Me End If If Range("I2") <= 0 Then MsgBox ("The Monster has died.") MsgBox (" You find : " & Range("K3") & " Gold.") Range("G1") = Range("G1") + Range("K3") Shop.Show End If End Sub 

  TextBox8.Value = Range("H5") Else If TextBox4.Value = "Magic Blast" Then 

这应该是ElseIf

这是更好的:

 Private Sub Attack_Click() Application.Calculate If Range("H2") <= 0 Then MsgBox ("YOU DIED. GAME OVER") Unload Me End If If Range("I2") <= 0 Then MsgBox ("The Monster has died.") MsgBox (" You find : " & Range("K3") & " Gold.") Range("G1") = Range("G1") + Range("K3") Shop.Show End If If TextBox4.Value = "Basic Attack" Then Range("H2") = Range("H2") - Range("E2") Range("I2") = Range("I2") - Range("C2") - Range("H4") TextBox2.Value = Range("H2") TextBox3.Value = Range("H3") TextBox5.Value = Range("I2") TextBox6.Value = Range("I3") TextBox7.Value = Range("H4") TextBox8.Value = Range("H5") Else If TextBox4.Value = "Magic Blast" Then Range("I2") = Range("I2") - Range("I2") - Range("C3") - Range("H5") Range("H2") = Range("H2") - Range("E2") TextBox2.Value = Range("H2") TextBox3.Value = Range("H3") TextBox5.Value = Range("I2") TextBox6.Value = Range("I3") TextBox7.Value = Range("H4") TextBox8.Value = Range("H5") End If End If If Range("H2") <= 0 Then MsgBox ("YOU DIED. GAME OVER") Unload Me End If If Range("I2") <= 0 Then MsgBox ("The Monster has died.") MsgBox (" You find : " & Range("K3") & " Gold.") Range("G1") = Range("G1") + Range("K3") Shop.Show End If End Sub