Creating functions

The last example shows how you can use VBA built-in functions in your procedures. You can also create your own custom functions in VBA. Creating a function is not quite the same thing as a sub, for a function always has a specific obj ective - to return a v alue! This is the key difference b etween a function and an ordinary procedure. In general, you should use functions rather than subs to create custom procedures.

A value returned by a function could be anything from a string to a numeric value, such as an integer, or even a Boolean true orfalse to inform the calling statement that the function has succeeded or failed.

0 0

Post a comment