Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
15 minutes early Glenn_H Excel Discussion (Misc queries) 4 January 31st 08 06:44 PM
Exit Field vs Exit Button...... roy_ware Excel Programming 2 October 10th 07 04:05 PM
A Sub/Function to cause another Sub/Function to Exit IT_roofer Excel Programming 7 August 23rd 07 05:12 PM
End sub early if mismatch achidsey Excel Programming 2 November 9th 05 07:26 PM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM


All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"