4 Replies Latest reply on Oct 14, 2015 5:01 PM by bala

    Please help me for scripting VBA PI Processbook about multi trend

    99anger

      I want to display multi trace trend by click MS Command Button.

      I have three tags naming "A001", "A002", "A003" and two command button naming " Button1", "Button2"

      First, I create trend plot using Trend Icon docked toolbar,the name is Trend1. And create two MS Command Button "Button1", "Button2"

      If click "Button1" then show all trace in one trend of three tags

      And If click "Button2" then clear all trace

      In addition, I want trace time span is 10minutes from now

      Please Help me...

        • Re: Please help me for scripting VBA PI Processbook about multi trend
          bala

          try this code:

           

          Function adlivetrend(tagname1 As String, tagname2 As String, tagname3 As String)

           

            Dim i As Integer

           

            Trend1.SetStartAndEndTime Format(DateAdd("n", -10, Now), "dd-mmm-yy hh:nn:ss"), Format(Now, "dd-mmm-yy hh:nn:ss")

           

          If Trend1.TraceCount = 0 Then

                      Trend1.AddTrace tagname1

                      Trend1.AddTrace tagname2

                      Trend1.AddTrace tagname3

                    

                 Else

                

                      For i = 0 To 2

                      Trend1.RemoveTrace (1)

                      Next i

                                 

                      Trend1.AddTrace tagname1

                      Trend1.AddTrace tagname2

                      Trend1.AddTrace tagname3

           

                  End If

           

            End Function

           

          -------------------

          Private Sub CommandButton1_Click()

          Call adlivetrend("sinusoid", "CDT158", "CDM158")

          End Sub

           

          Private Sub CommandButton2_Click()

          If Trend1.TraceCount = 3 Then

          Dim i As Integer

          For i = 0 To 2

                      Trend1.RemoveTrace (1)

                     

                    Next i

                     End If

          End Sub