CitectVBA Programming Reference > Understanding CitectVBA Language Basics > Constants

Constants

Your CitectVBA code may contain frequently recurring constant values like Pi, or may contain numbers that are difficult to remember or have no obvious meaning. You can make your CitectVBA code much easier to read and maintain using constants to represent those values.

Unlike variables, constants can't be changed once your CitectSCADA project is compiled and running. Constants are either symbolic or intrinsic:

You can create a constant in CitectVBA named Pi, assign it the numeric value once in your code, then refer to it by using the constant name, as shown here:

'modular level constant declaration
Const Pi = 3.1415926
Function CircleArea(Byval Radius)
' calculate and return area of circle
' using radius passed in as argument
CircleArea = Pi * (Radius * Radius)
End Function
Function CircleCircumference(Byval Radius)
' calculate and return circumference of circle
' using radius passed in as argument
CircleCicumference = Pi * Radius * 2
End Function

These CitectVBA functions would be called from a CitectSCADA command or expression field like this:

CiVBA
TestTag_1 = CircleArea(TestTag_1)

or

CiVBA
TestTag_1 = CircleCircumference(TestTag_1)

See Also

Declaration of constants

Passing variables Byref and Byval

Integrating CitectVBA with CitectSCADA

Intrinsic constants

Scope of CitectVBA

CitectVBA Function Reference