AnsweredAssumed Answered

How to apply to Listview Control several tag vlaue

Question asked by 99anger on Sep 2, 2017

Hi everyone.

First of all, I'm beginner to PB and VAB

In order to get event of tag status, I would to use ListView on VBA.

When a tag value(= On or Off) meets the condition during selected time,  time stamp and staus are added.

My code is next (for your reference, sample tag is the valve) :


Private Sub CommandButton1_Click()

  Dim pt As PIPoint
  Dim pts As PIPoints
  Dim svr As Server
  Dim tagName As String

  tagName = "SB_MV01.PV"

  Set svr = PISDK.Servers("JJ")
  Set pt = svr.PIPoints(tagName)

  Dim pv As PIValue
  Set pv = pt.Data.Snapshot

  Dim sdate As Variant
  Dim edate As Variant
  sdate = DTPicker1.value
  edate = DTPicker2.value

  Dim items As ListItems
  Dim item As Variant

  ListView1.ColumnHeaders.Add , , "Time", 130
  ListView1.ColumnHeaders.Add , , "Status", 100

  Set item = ListView1.ListItems.Add
   If pv.value = "ON" Then 
   item.Text = pv.TimeStamp.LocalDate
   item.SubItem(1) = "MV01 Open"
   item.Text = pv.TimeStamp.LocalDate
   item.SubItem(1) = "MV01 Close"
   End if

End Sub


In addition to my code, I want to list up another tag status (the tag name is SB_MV02.PV) on the same Listview

SO, whenever SB_MV01.PV or SB_MV02.PV status is changed their event is listed up side by side.


And Can I get the event only when SB_MV01 or SB_MV02 is "ON"


How to modify my code? Please.