• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Functions and Subroutines

You can create two types of procedures in Visual Basic—functions and subroutines—also known as Function procedures and Sub procedures. (As you’ll learn later in the section “Understanding Class Modules,” class modules also support a special type of function—Property Get, and special subroutines—Property Let and Property Set, that let you manage properties of the class.) Each type of procedure can accept parameters—data variables that you pass to the procedure that can determine how the procedure operates. Functions can return a single data value, but subroutines cannot. In addition, you can execute a public function from anywhere in Microsoft Access, including from expressions in queries and from macros. You can execute a subroutine only from a function, from another subroutine, or as an event procedure in a form or a report.

Function Statement

Use a Function statement to declare a new function, the parameters it accepts, the variable type it returns, and the code that performs the function procedure.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint