CitectVBA Programming Reference > Integrating CitectVBA into a Project > Using CitectVBA in Command or Expression fields

Using CitectVBA in Command or Expression fields

Citect SCADA expects that all code contained within a Citect SCADA Command or Expression field to be Cicode by default. When using CitectVBA code script directly in a Citect SCADA Command or Expression field within Citect SCADA, you must precede the CitectVBA script with the keyword CiVBA, as shown here:

CiVBA
TestTag_1 = TestTag_1 + 1

This is known as the language override command. When the Citect SCADA compiler reads the keyword CiVBA, it knows to handle that code (within the same Citect SCADA Command or Expression field) as CitectVBA script, and compiles it as such. No such override command is required to use Cicode.

The CiVBA language override statement must be placed first in the Citect SCADA Command or Expression field if you want to use CitectVBA script code instead of Cicode in that Citect SCADA Command or Expression field.

Note: You must use either Cicode or CitectVBA in a Citect SCADA Command or Expression field. You cannot change or swap between the two programming languages (within the same Citect SCADA Command or Expression field) once you've started using one or the other.

You can, however, call a single Cicode function from within CitectVBA script if you wrap the Cicode call within special CitectVBA functions CicodeCallOpen()and CicodeCallReturn().

Alternatively, to call a single CitectVBA function (from within the Citect SCADA Command or Expression field) after you have already used Cicode in that field, you can wrap the CitectVBA within three nested special Cicode functions: VbCallOpen(), VbCallRun()and VbCallReturn().

See Also

Accessing Cicode Tags with CitectVBA

Accessing ActiveX Objects with CitectVBA

Multithread Considerations with CitectVBA

Calling CitectVBA from Cicode

Calling Cicode from CitectVBA

Published June 2018