By Reference (ByRef) and By Value (ByVal)

This relates to the passing of parameters. A parameter is a variable that is passed into a sub program. It can be passed one of two ways.

  • ByVal – the sub program is given a copy of the data. This means that it can not pass any changes to it to the main program.
  • ByRef – the sub program is given the memory reference for the variable. This means that it can change the variable and that any changes will be passed back to the main program.

Rule of thumb ByVal=In, ByRef=Out