Applies To:
  • CitectSCADA 6.xx, 7.xx
  • Vijeo Citect 6.xx, 7.xx

Summary:
I would like to use the CitectVBA Format function to insert thousands separators into my larger numbers so as to make them easier to read. However, if I pass in a Variable Tag directly the Format function will just return a blank string.

Solution:
When using the CitectVBA built-in functions, you cannot pass in a Variable Tag as an argument. As a workaround, you could write your own CitectVBA function which accepts an argument by value and then pass in the Variable Tag into that function. Below is an example of this:

Function formatTheVarTag(Byval iInVal As Integer) As string
   Dim sFormattedValue As String
   Dim iTagValue As Integer
   iTagValue = iInVal
   sFormattedValue = Format(iTagValue,"Standard")
   formatTheVarTag=sFormattedValue
End Function

After placing this function into a CitectVBA file you can display the result on a page. When using CitectVBA code script directly in a Command or Expression field within an object on a graphics page, you must precede the CitectVBA script with the keyword CiVBA, as shown in this Text Object example:

CiVBA formatTheVarTag(theVarTag)

Now if theVarTag is 1234, then resulting string displayed is "1,234.00".

Keywords:
 Format, CitectVBA, CiVBA

Attachments