Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Subroutines and Functions

  • Last UpdatedJul 18, 2023
  • 1 minute read

Commonly used sequences of VBA statements can be grouped together into functions and subroutines, so that they can be keyed in once, and used many times in many places, by 'calling' the name of the subroutine or function in code.

A subroutine or function is a group or list of sequential statements that VBA can perform (execute) in the logical order that they exist within the subroutine or function from top to bottom in the order they are listed within the function or subroutine.

If the group of statements returns a value, it must be declared as a function. If it does not return a value, it must be declared as a subroutine. A subroutine or function is called by placing the name of the subroutine or function in a code statement where you want the action of the subroutine or function to occur.

Note: Subroutines and functions can contain statements that call other subroutines or functions (to perform, before returning to the following statements within the calling subroutine or function).

Both subroutines and functions can similarly be passed values as arguments when they are called:

  • Arguments are passed to subroutines in VBA code following the subroutine name and separated by space characters.

  • Arguments are passed to functions enclosed within parentheses in VBA code, similarly following the subroutine name and separated by space characters.

    Note: Plant SCADA tag values must be declared by value when passed as argument values to a VBA procedure from within a Plant SCADA command or expression field (see Passing Variables Byref and Byval).

See Also

Subroutines

Functions

Arguments

TitleResults for “How to create a CRG?”Also Available in