TM80 TM80 - 6 months ago 18
Vb.net Question

Calling another sub then returning to first sub to continue (vb.net)

Is it possible to have a function that cuts to another function and when that step is complete return to the first fuction again...? at the moment I can only switch to another sub but not return and continue where I left
example:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

msgbox("Hello step 1")

Call SECONDSTEP()

msgbox("Hello step3")
end sub

Answer

Your execution will always return to calling function. in this example three message box display in sequence step1, step2, step3. But if sub function contain close() then execution will not return to calling function.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("step 1")

        Call SECONDSTEP()

        MsgBox("step3")
    End Sub

    Private Sub SECONDSTEP()
        MsgBox("step2")
    End Sub
Comments