Applies To:
  • CitectSCADA
  • VijeoCitect 

Summary:
The following CiVBA error occurs at compilation: "Error on line <XXX>: - Duplicate definition: vbTab"
When opening the 'faulty' BAS file, the line containing the error cannot be found. (e.g .bas file contains 100 lines of VBA code, but compiler reported error on line 133).
CiVBA functions and constants are defined in multiple Citect BAS files.

Solution:
When using constants in CiVBA, the rules below must be followed:
 - Constants declared in one .bas file cannot be used in another .bas file.
 - The same constant name cannot be used in multiple .bas files.

Defining many constants in multiple .BAS files, without respecting the above rules, causes the CiVBA compiler to generate errors.
We usually recommend using only one .BAS file to develop all CiVBA code and to use cicode instead of CiVBA, whenever it is possible.

In some circumstances, such as CiVBA .BAS file's limitation is reached (Further details available in KB article Q4305), writing all VBA code in only one .BAS file is not possible. Therefore, multiple .BAS files need to be created and same constant may need to be used in all the .BAS files.
In order to get around the CiVBA constant limitations, constants should be defined in a global function. See example below:

    Const vbCr As integer = 13

Should be replaced by:

    Public Function vbCr() As Integer
        vbCr = 13
    End Function


In each .BAS file, replace constant vbCr by the global function vbCr().

Keywords:
 CiVBA, Compiler, Error, Constant

Attachments