'exit function'...always use it when returning a value?

  • Thread starter Thread starter darrel
  • Start date Start date
D

darrel

This might be a really dumb question, but when should/shouldn't one use the
exit function command?

If I have this:

function()
if something then
do this
return that
else
do this
return that
end if
end function

should I instead always use this instead:

function()
if something then
do this
return that
exit function
else
do this
return that
exit function
end if
end function

or does the very act of returning something exit the function?
 
"or does the very act of returning something exit the function?" <-- yes

You really only would need to use exit function if you were familiar with the old VB6 way of functions, where you had to set the function name = return value. But using the return statement immediately exits the function (and why shouldn't it?)
 
The very act of returning, exits the function immediately.

Thanks, Raterus and Marina...I figured as much but just wanted to confirm!

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top