Excel可视血管块如果没有结束如果

Excel可视血管块如果没有结束如果,excel,Excel,我正在使用excel电子表格和visual basic设计一个游戏。 当我试图编译“Block if without end if”时,我有一个错误。4.我已经找遍了,想找出解决这个问题的办法 请帮忙 这是我的密码 Private Sub Attack_Click() Application.Calculate If Range("H2") <= 0 Then MsgBox ("YOU DIED. GAME OVER") Unload Me End If If Range("I2")

我正在使用excel电子表格和visual basic设计一个游戏。 当我试图编译“Block if without end if”时,我有一个错误。4.我已经找遍了,想找出解决这个问题的办法

请帮忙

这是我的密码

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
私有子攻击\u Click()
应用。计算
中频范围(“H2”)
这应该是
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
私有子攻击\u Click()
应用。计算

如果范围(“H2”)缩进,它将帮助您查看丢失代码的位置。我过去常做缩进(因为我真的很擅长遗忘)
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