Vb.net ';其他';前面必须有匹配的';如果';或';ElseIf';

Vb.net ';其他';前面必须有匹配的';如果';或';ElseIf';,vb.net,visual-studio-2010,Vb.net,Visual Studio 2010,由于此错误,我无法运行我的程序。有人能帮我吗?谢谢。 公共类登录 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If tbx_username.Text <> "" And tbx_pass.Text <> "" Then Dim SM As New SubjectMaintenance

由于此错误,我无法运行我的程序。有人能帮我吗?谢谢。

公共类登录

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
        Dim SM As New SubjectMaintenance
        Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)

        While dr.Read
            GUI.accnt.pData_id = dr(Account.si_data_id)
            Me.Hide()
            GUI.Show()
    **Else**

            GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
            GUI.accnt.pData_username = dr(Account.si_data_username)
            GUI.accnt.pData_lname = dr(Account.si_data_lname)
            GUI.accnt.pData_fname = dr(Account.si_data_fname)
            GUI.accnt.pData_mname = dr(Account.si_data_mname)
        End While
        SM.closeConDr()
        If GUI.accnt.pData_id > 0 Then
            MessageBox.Show("Login Failed!")
        End If
    End If
End Sub
Private子按钮1\u单击(发送方作为System.Object,e作为System.EventArgs)处理按钮1。单击
如果tbx_username.Text“”和tbx_pass.Text“”,则
Dim-SM作为一门新学科
Dim dr=SM.openSel(SqlString.getSQLSelect(Account.tablename,Account.si_data_username&“=”&tbx_username.Text&“&Account.si_data_pwd&“=”&tbx_pass.Text&“”),CommandType.Text)
当雷德博士
GUI.accnt.pData\u id=dr(Account.si\u data\u id)
我躲起来
GUI.Show()
**否则**
GUI.accnt.pData\u pwd=dr(Account.si\u data\u pwd)
GUI.accnt.pData\u username=dr(Account.si\u data\u username)
GUI.accnt.pData\u lname=dr(Account.si\u data\u lname)
GUI.accnt.pData\u fname=dr(Account.si\u data\u fname)
GUI.accnt.pData\u mname=dr(Account.si\u data\u mname)
结束时
SM.closeConDr()
如果GUI.accnt.pData_id>0,则
MessageBox.Show(“登录失败!”)
如果结束
如果结束
端接头

End Class

您不能在
while End while
中放置
else
,而
if else End if
while End while
是独立的语句,因此您可以按如下方式混合它们:

while
 if
 else
 end if
end while


分解嵌套语句的唯一方法是
GoTo
语句,它将指令指针无条件地移动到指定的标签。

您不能将
else
放在
中而end while
中,如果else end if和
而end while
是独立语句,因此,您可以按如下方式混合它们:

while
 if
 else
 end if
end while
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
    Dim SM As New SubjectMaintenance
    Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)

    While dr.Read
        GUI.accnt.pData_id = dr(Account.si_data_id)
        Me.Hide()
        GUI.Show()

    End While
**Else**  'Try moving the else below the end while or above the while

        GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
        GUI.accnt.pData_username = dr(Account.si_data_username)
        GUI.accnt.pData_lname = dr(Account.si_data_lname)
        GUI.accnt.pData_fname = dr(Account.si_data_fname)
        GUI.accnt.pData_mname = dr(Account.si_data_mname)
    SM.closeConDr()
    If GUI.accnt.pData_id > 0 Then
        MessageBox.Show("Login Failed!")
    End If
  End If
End Sub


分解嵌套语句的唯一方法是
GoTo
语句,它将指令指针无条件地移动到指定的标签。

您不能将
else
放在
中而end while
中,如果else end if和
而end while
是独立语句,因此,您可以按如下方式混合它们:

while
 if
 else
 end if
end while
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
    Dim SM As New SubjectMaintenance
    Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)

    While dr.Read
        GUI.accnt.pData_id = dr(Account.si_data_id)
        Me.Hide()
        GUI.Show()

    End While
**Else**  'Try moving the else below the end while or above the while

        GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
        GUI.accnt.pData_username = dr(Account.si_data_username)
        GUI.accnt.pData_lname = dr(Account.si_data_lname)
        GUI.accnt.pData_fname = dr(Account.si_data_fname)
        GUI.accnt.pData_mname = dr(Account.si_data_mname)
    SM.closeConDr()
    If GUI.accnt.pData_id > 0 Then
        MessageBox.Show("Login Failed!")
    End If
  End If
End Sub


分解嵌套语句的唯一方法是
GoTo
语句,它将指令指针无条件地移动到指定的标签。

您不能将
else
放在
中而end while
中,如果else end if和
而end while
是独立语句,因此,您可以按如下方式混合它们:

while
 if
 else
 end if
end while
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
    Dim SM As New SubjectMaintenance
    Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)

    While dr.Read
        GUI.accnt.pData_id = dr(Account.si_data_id)
        Me.Hide()
        GUI.Show()

    End While
**Else**  'Try moving the else below the end while or above the while

        GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
        GUI.accnt.pData_username = dr(Account.si_data_username)
        GUI.accnt.pData_lname = dr(Account.si_data_lname)
        GUI.accnt.pData_fname = dr(Account.si_data_fname)
        GUI.accnt.pData_mname = dr(Account.si_data_mname)
    SM.closeConDr()
    If GUI.accnt.pData_id > 0 Then
        MessageBox.Show("Login Failed!")
    End If
  End If
End Sub

分解嵌套语句的唯一方法是
GoTo
语句,它将指令指针无条件地移动到指定的标签。

Private子按钮1\u单击(发送方作为System.Object,e作为System.EventArgs)处理按钮1。单击
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
    Dim SM As New SubjectMaintenance
    Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)

    While dr.Read
        GUI.accnt.pData_id = dr(Account.si_data_id)
        Me.Hide()
        GUI.Show()

    End While
**Else**  'Try moving the else below the end while or above the while

        GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
        GUI.accnt.pData_username = dr(Account.si_data_username)
        GUI.accnt.pData_lname = dr(Account.si_data_lname)
        GUI.accnt.pData_fname = dr(Account.si_data_fname)
        GUI.accnt.pData_mname = dr(Account.si_data_mname)
    SM.closeConDr()
    If GUI.accnt.pData_id > 0 Then
        MessageBox.Show("Login Failed!")
    End If
  End If
End Sub
如果tbx_username.Text“”和tbx_pass.Text“”,则 Dim-SM作为一门新学科 Dim dr=SM.openSel(SqlString.getSQLSelect(Account.tablename,Account.si_data_username&“=”&tbx_username.Text&“&Account.si_data_pwd&“=”&tbx_pass.Text&“”),CommandType.Text) 当雷德博士 GUI.accnt.pData\u id=dr(Account.si\u data\u id) 我躲起来 GUI.Show() 结束时 **Else**'尝试将Else移动到末端下方的while或上方的while GUI.accnt.pData\u pwd=dr(Account.si\u data\u pwd) GUI.accnt.pData\u username=dr(Account.si\u data\u username) GUI.accnt.pData\u lname=dr(Account.si\u data\u lname) GUI.accnt.pData\u fname=dr(Account.si\u data\u fname) GUI.accnt.pData\u mname=dr(Account.si\u data\u mname) SM.closeConDr() 如果GUI.accnt.pData_id>0,则 MessageBox.Show(“登录失败!”) 如果结束 如果结束 端接头
'尝试将else移动到末尾下方,同时将其移动到while

私有子按钮1\u单击(发件人作为System.Object,e作为System.EventArgs)句柄按钮1。单击
如果tbx_username.Text“”和tbx_pass.Text“”,则
Dim-SM作为一门新学科
Dim dr=SM.openSel(SqlString.getSQLSelect(Account.tablename,Account.si_data_username&“=”&tbx_username.Text&“&Account.si_data_pwd&“=”&tbx_pass.Text&“”),CommandType.Text)
当雷德博士
GUI.accnt.pData\u id=dr(Account.si\u data\u id)
我躲起来
GUI.Show()
结束时
**Else**'尝试将Else移动到末端下方的while或上方的while
GUI.accnt.pData\u pwd=dr(Account.si\u data\u pwd)
GUI.accnt.pData\u username=dr(Account.si\u data\u username)
GUI.accnt.pData\u lname=dr(Account.si\u data\u lname)
GUI.accnt.pData\u fname=dr(Account.si\u data\u fname)
GUI.accnt.pData\u mname=dr(Account.si\u data\u mname)
SM.closeConDr()
如果GUI.accnt.pData_id>0,则
MessageBox.Show(“登录失败!”)
如果结束
如果结束
端接头
'尝试将else移动到末尾下方,同时将其移动到while

私有子按钮1\u单击(发件人作为System.Object,e作为System.EventArgs)句柄按钮1。单击
如果tbx_username.Text“”和tbx_pass.Text“”,则
Dim-SM作为一门新学科
Dim dr=SM.openSel(SqlString.getSQLSelect(Account.tablename,Account.si_data_username&“=”&tbx_username.Text&“&Account.si_data_pwd&“=”&tbx_pass.Text&“”),CommandType.Text)
当雷德博士
GUI.accnt.pData\u id=dr(Account.si\u data\u id)
我躲起来
GUI.Show()
结束时
**Else**'尝试将Else移动到末端下方的while或上方的while
GUI.accnt.pData\u pwd=dr(Account.si\u data\u pwd)
GUI.accnt.pData\u username=dr(Account.si\u data\u username)
GUI.accnt.pData\u lname=dr(Account.si\u data\u lname)
GUI.accnt.pData\u fname=dr(Account.si\u data\u fname)
GUI.accnt.pData\u mname=dr(Account.si\u data\u mname)
SM.closeConDr()
如果GUI.accnt.pData_id>0,则
MessageBox.Show(“登录失败!”)
如果结束
如果结束
端接头
'尝试将else移动到末尾下方,同时将其移动到while

专用子按钮1\u单击(发件人为S