阻止结束,如果没有if

时间:2014-07-13 19:18:59

标签: vba powerpoint-vba

Sub CommandButton2_Click()
    If TextBox2.Text = "qwerty1234" Then
        ActivePresentation.SlideShowWindow.View.Next
        Dim x As Integer
        For x = 5 To 7
            ActivePresentation.Slides(x).SlideShowTransition.Hidden = msoTriStateToggle
        Next x
    End
    Else
        If MsgBox("Did you forget your password? Try again, ensuring you use the correct case.", vbOKOnly + vbCritical, "Sorry!") = vbOK Then
        End If
End Sub

2 个答案:

答案 0 :(得分:1)

正如GS所说,你需要第二个结束If(并删除结束)即便如此,虽然你的代码没有意义,你想在消息之后想要发生什么?

也许你的意思是:

    Private Sub CommandButton2_Click()

 If TextBox2.Text = "qwerty1234" Then
 ActivePresentation.SlideShowWindow.View.Next
 Dim x As Integer
 For x = 5 To 7
 ActivePresentation.Slides(x).SlideShowTransition.Hidden = msoTriStateToggle
 Next x
 Else
 MsgBox "Did you forget your password? Try again, ensuring you use the correct case.", vbOKOnly + vbCritical, "Sorry!"
 TextBox2.Text = ""
 End If
 End Sub

答案 1 :(得分:0)

您需要另一个End If。你有一个,但你有两个If陈述。