views:

29

answers:

1

Is there a way to stop other subs from running while in a separate sub.

for instance say your in the sub CreateNumber()

and the subs are setup like

CreateNumber()
AddNumber()
DeleteNumber()

Is there a way to be in CreateNumber() and call a function to stop AddNumber from running after creaetNumber() is finished? i just want my program to sit there to wait for an event to happen.

+1  A: 

Just do this:

CreateNumber()
WaitForSomeEventToHappen()
AddNumber()
DeleteNumber() 

If you're not using threads, then these Subs will simply be called in sequence, so you don't have to do anything "clever".

If you want CreateNumber to be able to control whether or not AddNumber() will be executed, then you can make it into a Function and return a result - e.g.

Public Function CreateNumber() As Boolean
    ...create the number...

    if (numberCreatedOk)
        return(True);

    return(False);
End Function

Then call it like this:

if (CreateNumber()) then
    AddNumber()
    DeleteNumber()
end if

In this way, you only call the remaining Subs if CreateNumber() returned True.

Jason Williams
oh i see, thank you very much.
Bigfatty