exit a calling sub using current sub at half of a code
i used v s 2008.. i create a windows form application in vb.net i want help in which .........if i exit a sub *check_fill_for_New()* using EXIT SUB then in *bt_Ok_Click* sub not fire a msgbox......but it will also EXIT at half
Public Sub check_fill_for_New()
If tb_UserName.Text = "" Then
MsgBox("Please Insert User Name Field", MsgBoxStyle.OkOnly, "Error")
tb_UserName.Focus() 开发者_Go百科
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
You need a function that will return a result indicating if you want to continue from your calling procedure.
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
Side note: It seems that you might be new to VB.NET as your naming conventions is not standard with the .NET framework. Have a look at the VB.NET coding conventions here: http://msdn.microsoft.com/en-us/library/h63fsef3.aspx
精彩评论