Visual Basic Tutorial – Point Edit – Step 4 code:

Option Explicit
Dim srv As Server
Dim pt As PIPoint

Private Sub Combo1_Click()
   Set srv = Servers(Combo1.Text)
End Sub

Private Sub Command1_Click()
On Error GoTo handler
   If Text1.Text = "" Then
      MsgBox "Please enter a tagname"
      Exit Sub
   End If
   Set pt = srv.PIPoints(Text1.Text)
   Dim ptatr As PointAttribute
   List1.Clear
   For Each ptatr In pt.PointAttributes
      List1.AddItem ptatr.Name
   Next
Exit Sub
handler:
   MsgBox Err.Description
End Sub

Private Sub Command2_Click()
Dim Cxn As New PISDKDlg.Connections
Dim s As PISDK.Server
On Error Resume Next
   Set s = Cxn.Login(srv, , , True)
   If Err.Number <> 0 Then
      MsgBox Err.Description
   Else
      If s.Connected Then
         MsgBox "Successfully connected to " & s.Name
      End If
   End If
End Sub

Private Sub Command3_Click()
On Error GoTo handler
Dim ptatr As PointAttribute
   If pt Is Nothing Then
      MsgBox "Please retrieve attributes for a tag first."
      Exit Sub
   End If
   If Label4.Caption = "" Then
      MsgBox "Please select an attribute to modify"
      Exit Sub
   End If
   Set ptatr = pt.PointAttributes(Label4.Caption)
   pt.PointAttributes.ReadOnly = False
   ptatr.Value = Text2.Text
   pt.PointAttributes.ReadOnly = True
   MsgBox "Modification succeeded"
Exit Sub
handler:
   MsgBox Err.Description
End Sub

Private Sub Form_Load()
   Dim cur As Integer
   Dim dflt As Integer
   cur = 0
   dflt = 0
   For Each srv In Servers
      Combo1.AddItem srv.Name
      If srv.Name = Servers.DefaultServer.Name Then
         dflt = cur
      End If
      cur = cur + 1
   Next
   Combo1.ListIndex = dflt
   Set srv = Servers(Combo1.Text)
End Sub

Private Sub List1_Click()
   Label4.Caption = List1.Text
   Text2.Text = CStr(pt.PointAttributes(List1.Text).Value)
End Sub


Enabling Operational Intelligence