Vb.net 在代码的一半处使用当前sub退出调用sub
我用的是v s 2008。。 我在vb.net中创建了一个windows窗体应用程序 我需要帮助,其中………如果我退出sub*请使用 退出SUB然后在*bt_Ok_单击*SUB不发射msgbox……但它也会在一半时退出Vb.net 在代码的一半处使用当前sub退出调用sub,vb.net,Vb.net,我用的是v s 2008。。 我在vb.net中创建了一个windows窗体应用程序 我需要帮助,其中………如果我退出sub*请使用 退出SUB然后在*bt_Ok_单击*SUB不发射msgbox……但它也会在一半时退出 Public Sub check_fill_for_New() If tb_UserName.Text = "" Then MsgBox("Please Insert User Name Field", MsgBoxStyle.
Public Sub check_fill_for_New()
If tb_UserName.Text = "" Then
MsgBox("Please Insert User Name Field", MsgBoxStyle.OkOnly, "Error")
tb_UserName.Focus()
Exit Sub
End If
End Sub
Private Sub bt_Ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_Ok.Click
If maintain_department = "Admin" Then
Call check_fill_for_New()
MsgBox("nooooooooo")
End If
End Sub
您需要一个函数,该函数将返回一个结果,指示是否要从调用过程继续
Public Function check_fill_for_New() as Boolean
If tb_UserName.Text = "" Then
MsgBox("Please Insert User Name Field", _
MsgBoxStyle.OkOnly,_
"Error")
tb_UserName.Focus()
return True
Else
return False
End If
End Sub
Private Sub bt_Ok_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles bt_Ok.Click
If maintain_department = "Admin" Then
If (check_fill_for_New()) Then
MsgBox("nooooooooo")
End If
End If
End Sub
旁注:您可能是VB.NET新手,因为您的命名约定在.NET framework中不是标准的。请在此处查看VB.NET编码约定: