April 20, 2024, 02:56:55 AM
Forum Rules: Read This Before Posting


Topic: Using vector user variable in HYSYS  (Read 400 times)

0 Members and 1 Guest are viewing this topic.

Offline Zsolt Ulbert

  • Very New Member
  • *
  • Posts: 2
  • Mole Snacks: +0/-0
Using vector user variable in HYSYS
« on: March 03, 2024, 06:17:56 PM »
Hi!
I would like to use a vector user variable in Hysys V14. For example, I  prepared the following code to create a vector user variable using stream temperature:
 
Sub PostExecute()
    Dim hysysuv As HYSYS.InternalRealFlexVariable
    Dim varVals As Variant
    Dim Count As Integer
    Dim myFluid As Object
    On Error GoTo GetOut
    Set myFluid = ActiveObject.DuplicateFluid
    'Linking to wrapper to hysysuv variable
    Set hysysuv = ActiveVariableWrapper.Variable
    'Setting the range
    hysysuv.SetBounds 2,0,0
    'Retrieving an array of values
    varVals = hysysuv.Values
    'Calculating values using stream temperature
    For Count = 0 To 1
            varVals(Count)= Count*myFluid.Temperature
    Next
    'varVals into hysysuv
    hysysuv.SetValues varVals,"C"
    'Retrieving values (using unit Kelvin)
    varVals = hysysuv.GetValues  ("K")
GetOut:
End Sub
 
I debugged the code and it looks working well, but in the user variable property windows only the <Multidimensional> word is displayed for my multidim user variable (see the attached picture). When I try to send this variable to a spreadsheet object a <empty>  value is only inserted.
Does someone know how I can see the results of a vector variable variable and use its components?
 
Thanks,
Zsolt

Sponsored Links