PIPoint Example


This example, during the Form_Load, connects to the default server. The user types in a tag name and clicks Command1. The code in the Click event retrieves the PIPoint from the server's PIPoints collection and then retrieves selected PIPoint properies and displays them.


Build the PIPoint example as follows:

1. Create a new project and add 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 a tag name whose properties you wish to view."
    Exit Sub
  End If
  Dim pt As PIPoint
  Set pt = srv.PIPoints(Text1.Text)
  ShowProps pt
Exit Sub
  MsgBox Err.Description
End Sub

Private Sub Form_Load()
On Error GoTo handler
  Set srv = Servers.DefaultServer
  Text1.Text = ""
Exit Sub
  MsgBox Err.Description
End Sub
Private Sub ClearLabels()
  Label5.Caption = ""
  Label6.Caption = ""
  Label7.Caption = ""
  Label8.Caption = ""
  Label12.Caption = ""
End Sub
Private Sub ShowProps(pt As PIPoint)
  Label5.Caption = pt.Name
  Label6.Caption = pt.PathName
  Label7.Caption = pt.Server.Name
  Label8.Caption = PointTypeString(pt.PointType)
  Label12.Caption = pt.PointClass.Name
End Sub
Private Function PointTypeString(ptType As PointTypeConstants) As String
On Error GoTo handler
  Select Case ptType
    Case pttypBlob
      PointTypeString = "Blob"
    Case pttypDigital
      PointTypeString = "Digital"
    Case pttypFloat16
      PointTypeString = "16-bit float"
    Case pttypFloat32
      PointTypeString = "32-bit float"
    Case pttypFloat64
      PointTypeString = "64-bit float"
    Case pttypInt16
      PointTypeString = "16-bit integer"
    Case pttypInt32
      PointTypeString = "32-bit integer"
    Case pttypString
      PointTypeString = "String"
    Case pttypNull
      PointTypeString = "Unknown point type"
  End Select
Exit Function
MsgBox Err.Description
End Function
Enabling Operational Intelligence