GetParametersSingleElement Function: Sample Code Microsoft® Visual Basic for Excel
Private Sub btnGetParametersSingleElement_Click()
Dim objtype, filter As String
Dim xlWB As Excel.Workbook
Set xlApp = Excel.Application
' Checks connection and open case
' SimAuto and caseopen are global variables
If Not SimAuto Is Nothing And caseopen Then
objtype = "bus"
Dim fieldArray As Variant
fieldArray = Array("Number", "Name", "kV", _
"Vpu", "Vangle")
Dim ValueArray As Variant
ValueArray = Array(1, 0, 0, 0, 0)
output = SimAuto.GetParametersSingleElement(objtype, fieldArray, ValueArray)
If output(0) <> "" Then
DisplayErrorMessage output(0)
Else
DisplayMessage "Succesful GetParametersSingleElement"
' Prepares additional worksheet
Set xlWB = xlApp.Workbooks.Add
' Copies list of devices in worksheet
With xlWB
Sheets("sheet2").Activate
Sheets("sheet2").Name = "GetParametersSingleElement"
With Sheets("GetParametersSingleElement")
Dim i As Integer
Range(Cells(1, 5), Cells(200, 7)).Clear
Cells(1, 1) = "List of Devices for " + objtype + ":"
' Setup fields as subheader
For i = LBound(fieldArray) To UBound(fieldArray)
Cells(2, i + 1) = fieldArray(i)
Next i
' Determine number of fields retrieved
Dim lowfld, highfld As Integer
lowfld = LBound(output(1), 1)
highfld = UBound(output(1), 1)
DisplayMessage "Number of Fields: " + Str(lowfld) + Str(highfld)
For i = lowfld To highfld
Cells(j + 3, i + 1) = output(1)(i)
Next i
End With
End With
End If
End If
End Sub