Passing Parameters

There are numerous occasions when you need to call a custom function or subroutine from another function or subroutine, and a variable you are using in the calling procedure is needed in the called procedure. You therefore pass the variable as a parameter to the called procedure. Whether the called procedure is in the same module, the same project, or is a method within a class on a remote server, passing variables from one procedure to the other is always the same.

The called procedure, and not the calling procedure, determines how the variable is passed from the calling to the called procedure. As the user of a called procedure, you have no control over how Visual Basic treats the passed parameters. As the author of a called procedure, it's up to you to decide how best to bring in variables from calling procedures.

Visual Basic allows you to pass variables between procedures and components in two ways. Within the function or subroutine definition, you specify either ByRef or ByVal for each of the variables in the argument list.

Was this article helpful?

0 0

Post a comment