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 |
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 |
All times are GMT +1. The time now is 12:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com