Specifications
Automation 2-69
2-69
17. The next 2 sub-routines reset the lbToValue label whenever
an option is selected in either the ddFromUnit or ddToUnit
combo box.
18. The final two sub-routines define the actions of the two
buttons: btConvert and btExit.
lbToValue.Caption = ""
Clears any text that appears in the lbToValue label.
End Sub
Signifies the end of the sub-routine. This line does not
need to be added.
Code Explanation
Code Explanation
Private Sub
ddFromUnit_Click()
Signifies the Start of the sub-routine.
lbToValue.Caption = ""
Clears any text that appears in the lbToValue label.
End Sub
Signifies the end of the sub-routine. This line does not need to
be added.
Code Explanation
Private Sub ddToUnit_Click()
Signifies the Start of the sub-routine.
lbToValue.Caption = ""
Clears any text that appears in the lbToValue label.
End Sub
Signifies the end of the sub-routine. This line does not need to
be added.
Code Explanation
Private Sub btConvert_Click()
Signifies the Start of the sub-routine.
Set hyApp = CreateObject("HYSYS.Application")
Set UCSM = hyApp.UnitConversionSetManager
Connects to HYSYS and the HYSYS Unit
Conversion Set Manager.
FromValue = CDbl(Val(ebFromValue.Text))
Takes the value entered in the ebFromValue text
box and converts in to a numerical variable type.
ebFromValue.Text = CStr(FromValue)
Set ebFromValue text box text equal to
FromValue double.
UCSNumber = ddUnitSet.ListIndex
FromNumber = ddFromUnit.ListIndex
ToNumber = ddToUnit.ListIndex
Gets current selection in the three drop-down lists
(combo boxes).
If FromNumber < 0 Or ToNumber < 0 Then
lbToValue.Caption = ""
Exit Sub
End If
If no selection is made in either the ddFromUnit
or ddToUnit combo boxes, exit the sub-routine.
Set UCS = UCSM.Item(UCSNumber)
Set FromUC = UCS.Item(FromNumber)
Set ToUC = UCS.Item(ToNumber)
Chooses a specific UCS from UCSM. It takes the
Unit conversion type you want to change from,
and the Unit Conversion type you want to change
to.