Zsolt Ulbert
Chemical
- Mar 3, 2024
- 2
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 <empty> is only inserted.
Does someone know how I can see the results of a vector variable variable and use its components?
Thanks,
Zsolt
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 <empty> is only inserted.
Does someone know how I can see the results of a vector variable variable and use its components?
Thanks,
Zsolt