Specifications

2-16 Automation Syntax
2-16
implicitly a variant. Variants have considerably more storage
associated with their use, so for a large application it is good
practice to limit the number of variants being used. It is also just
good programming practice to explicitly declare variables
whenever possible.
The dimensions of the array depend upon what property is being
called. The following table lists the most common properties
that return arrays and what is the dimension of the array.
The example below, shows how to get an array of stage
pressures in a column.
The hyOp object is declared as a ColumnOp as specified in
the type library. The operations collection is filtered to only
include columns by using the word “ColumnOp”. HyOp is set
to the first column in the operations collection.
HyStagePressure is set equal to an array of doubles returned
by the ColumnOp object. Since the number of stages in this
column may not be known the Ubound function is used to
determine the upper bound of the one dimensional array. A
property view prints out the pressure value for each stage in
the column.
The example below, accesses the VapourComponentFraction
Common Variant of HYSYS Returning Property
Component Mass Fractions One Dimensional array
Column Component Fraction Values Two Dimensional array
Interaction Parameters Two Dimensional array
Example 1: Using Variants in HYSYS
Dim hyOp As ColumnOp
Dim hyStagePressure As Variant
Set hyOp = hyCase.Flowsheet.Operations(“ColumnOp”).Item(0)
hyStagePressure = hyOp.PressureValues
For j = 0 To UBound(hyStagePressure)
MsgBox “Stage “ & j +1 & “ Pressure = “ & hyStagePressure(j)
Next j