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

AVEVA™ Plant SCADA

Function

  • Last UpdatedJul 18, 2023
  • 1 minute read

The Function statement declares and defines a function procedure, its name, parameters, and code to be enacted upon when the subroutine is called. Functions differ from subroutines in that functions return a value, whereas subroutines do not.

The required FunctionName is the name of the function being declared. The optional ArgList is the list of arguments used within the function.

A VBA function starts with the FUNCTION statement and finishes with the END FUNCTION statement. All other statements that lie between the FUNCTION and END FUNCTION statements will be executed by the function when called to do so.

Syntax

Function FunctionName [(ArgList)] [As type]

Call | End Function | Sub | End Sub |

Example

Function GetColor2( c% ) As Long

GetColor2 = c% * 25

If c% > 2 Then

GetColor2 = 255 ' 0x0000FF - Red

End If

If c% > 5 Then

GetColor2 = 65280 ' 0x00FF00 - Green

End If

If c% > 8 Then

GetColor2 = 16711680 ' 0xFF0000 - Blue

End If

End Function

Sub TestColor2

Dim I as integer

For I = 1 to 10

Print GetColor2(I)

Next I

End Sub

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