Hello-World
Hello-World

Reputation: 9555

Return exit from a function - is this possible

Is it possible to return an Exit from a function?

So that I can exit the Page_Load function using the function MyExit

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    MyExit()   'Exit

End Sub

Private Function MyExit() As Exit

    Return Exit 

End Function

Upvotes: 0

Views: 109

Answers (2)

gunakkoc
gunakkoc

Reputation: 1069

How about this?

Private Sub MyExit()

    End

End Sub

Upvotes: 0

SysDragon
SysDragon

Reputation: 9888

No, but you can set a flag like this:

Protected Sub Page_Load()
    Dim bExit as Boolean = MyExit()
    If bExit then Exit
End Sub

Private Function MyExit() As Boolean
    Dim bOk as Boolean

    '[...] 

    Return bOk
End Function

Upvotes: 2

Related Questions