我试图在一行上结束2 if语句。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If showing = True Then
Do
txtpassword.Text = ""
If txtpassword.Text = password Then
My_Private_Screen.Show()
Me.Hide()
showing = False
attempts = 0
ElseIf txtpassword.Text = "" Then
Do
If txtpassword.Text = password Then
My_Private_Screen.Show()
Me.Hide()
End If
Loop Until Inc = 5
Me.Hide()
showing = False
Do
Loop Until Inc2 = 300
Me.Show()
showing = True
Else
MessageBox.Show("Incorrect Password")
attempts = attempts + 1
Loop Until attempts = 5
Me.Hide()
End If
showing = False
所以我需要知道如何结束2 ifs。我想知道如何做这样的事情:
Me.Hide()
End If
End If
或者
Me.Hide()
End If End If
答案 0 :(得分:0)
你需要在循环之前结束内部If。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If showing = True Then
Do
txtpassword.Text = ""
If txtpassword.Text = password Then
My_Private_Screen.Show()
Me.Hide()
showing = False
attempts = 0
ElseIf txtpassword.Text = "" Then
Do
If txtpassword.Text = password Then
My_Private_Screen.Show()
Me.Hide()
End If
Loop Until Inc = 5
Me.Hide()
showing = False
Do
Loop Until Inc2 = 300
Me.Show()
showing = True
Else
MessageBox.Show("Incorrect Password")
attempts = attempts + 1
Endif
Loop Until attempts = 5
Me.Hide()
End If
showing = False