PISDK Application Example




This example demonstrates accessing the properties and methods available from the PISDK application object. During the Form_Load event the program retrieves the list of Known Servers from the Servers collection and fills a list box with the names. It retrieves the PISDKVersion object and displays the version and build ID. It obtains the global timeout property for the PI-SDK and displays it. It then clears the uninitialized TextBoxes and Labels. When Command1 is clicked, the click event code validates that some data has been entered for the error number. It then calls the GetErrorString method and if successful paints the results in Label6.


Build the PISDK application object example as follows:

1. Create a new project and adds a reference to the PISDK_library.

2. Add the visual elements as shown in the picture. Make sure the numbered element names (label1, list1, ...) match those shown.

3. Cut and paste the code below into the project.

Option Explicit
Dim srv As Server

Private Sub Command1_Click()
On Error GoTo handler
   If Text1.Text = "" Then
      MsgBox "Please enter an error number to retrieve."
      Exit Sub
   End If
   Label6.Caption = ""
   Dim errString As String
   errString = PISDK.GetErrorString(CLng(Text1.Text))
   Label6.Caption = errString
Exit Sub
MsgBox Err.Description 
End Sub
Private Sub Form_Load()
   For Each srv In PISDK.Servers
      List1.AddItem srv.Name
   Dim sdkver As PISDKVersion
   Set sdkver = PISDK.PISDKVersion
   Label3.Caption = sdkver.Version & "." & sdkver.BuildID
   Label5.Caption = PISDK.Timeout
   Text1.Text = ""
   Label6.Caption = ""
   Label8.Caption = "Error Number: (e.g. -2147220408 or &&H80040448 )"
End Sub
Enabling Operational Intelligence