Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early exit from function?
Suppose I have the following function:
'------------------------------------ Function foo(x as Integer) as Integer If (x < 1) Then foo = 1 ' Exit point? End If MsgBox "I hope I don't get this far." foo = 2 End foo '----------------------------------- Ideally, I'd like the function to exit as soon as I assign a value to the function name. So, if x = 0, then I'd like to immediately exit and have foo return 1. Is there a way to have functions exit as soon as they are assigned a value? Or do I need to hook up a bunch of "Goto" statements that jump to the last line? -Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early exit from function?
On 15/10/2019 08:42, RG III wrote:
Suppose I have the following function: '------------------------------------ Function foo(x as Integer) as Integer If (x < 1) Then foo = 1 ' Exit point? Exit Function https://docs.microsoft.com/en-us/dot...exit-statement -- Adrian C |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
15 minutes early | Excel Discussion (Misc queries) | |||
Exit Field vs Exit Button...... | Excel Programming | |||
A Sub/Function to cause another Sub/Function to Exit | Excel Programming | |||
End sub early if mismatch | Excel Programming | |||
If a called sub exit, how to the caller exit right away? | Excel Programming |