我目前遇到问题,因为我有一个组合框转换为下拉列表框,如果他们没有选择服务器内的服务器那么它就不会让他们登录。我已经发出了一个else语句但是当时他们没有正确选择服务器,然后它会弹出。我希望程序为这种错误使用正确的if语句。
代码:(整个代码)
If txtUsername.Text = My.Settings.Username And txtPassword.Text = My.Settings.Password And cmbServers.Text = "Redox Server" Then
stripStatus.Text = "Connecting to 'Redox Server; Please wait...'"
frmRedox.Show()
Me.Close()
Else
If txtUsername.Text = "" And txtPassword.Text = "" Then
MsgBox("Please input a username and password to login. If you do not have an account then you may create one.", MsgBoxStyle.Exclamation, "Redox - Error")
If cmbServers.Text = "" Then
MsgBox("Please select the server called 'Redox Server'.", MsgBoxStyle.Critical, "Redox - Server Connectivity Error")
End If
End If
End If
答案 0 :(得分:1)
您至少错过了“ EndIf ”或“ ElseIf ”。
Else
If ... Then
DoSomething
EndIf
If ... Then
DoSomething
EndIf
EndIf
或者可能是这样:
Else
If ... Then
DoSomething
ElseIf ... Then
DoSomething
EndIf
EndIf