For a function to return a value, it must include a function assignment statement that assigns a value to the name of the function, as shown in the following example. The value assigned to ConeSurface will be the value returned by the function.
Function ConeSurface(radius, height) Const Pi = 3.14159 coneBase = Pi * radius ^ 2 coneCirc = 2 * Pi * radius coneSide = Sqr(radius ^ 2 + height ^ 2) * coneCirc / 2 ConeSurface = coneBase + coneSide End Function
When the Function procedure returns a value, this value can then become part of a larger expression. For example, the following line in another procedure incorporates the return value of the ConeSurface and ScoopSurface functions into its calculations.
totalSurface = ConeSurface(3, 11) + 2 * ScoopSurface(3)
The information that must be supplied to a procedure for it to perform its task (radius and height in the preceding example) is passed in the form of arguments. For more information about arguments, see "Communicating with Procedures Using Arguments" later in this chapter.