Exit the caller subuser using the current sub in half the code

i used vs 2008 .. i'm building a windows form application in vb.net i need help that ......... if i exit sub * check_fill_for_New () * using EXIT SUB and then in * bt_Ok_Click * sub does not start msgbox ...... but it also EXIT in half

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
+3
source share
1 answer

You need a function that returns a result indicating whether you want to continue with your call 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

: , VB.NET, .NET. VB.NET : http://msdn.microsoft.com/en-us/library/h63fsef3.aspx

+6

Source: https://habr.com/ru/post/1781040/


All Articles