Chapter 36 User-Defined Subprograms

36.1 Subprograms that Return a Value

In Visual Basic and many other computer languages, a subprogram that returns a value is called a function. There are two categories of functions. There are the built-in functions, such as Fix(), and there are the user-defined functions, those that you can personally write and use in your own programs.

The general form of a Visual Basic function that returns a value is shown here.

Function name([arg1 As type1, arg2 As type2, arg3 As type3, …]) As return_type
Local variables declaration section
 
A statement or block of statements
Return value
End Function

where

name is the name of the function.
arg1, arg2, arg3, … is a list of arguments (variables, arrays etc.) used to ...

Get Visual Basic and Algorithmic Thinking for the Complete Beginner now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.