4 Replies Latest reply on Jun 10, 2015 3:52 PM by dng

    VBA to display trend trace last value in a pdi text box

    bryancouch

      Hello,

      I have found several snippets that almost do what I want, but not quite.  I am looking for code to grab the last value of a trace (from a trend with 6 traces) and display the last value of each trace in a text box in a pdi display.

       

      textbox1 = trend 1 trace 1 last value

      textbox2 = triend 1 trace 2 last value

      textbox3 = trend 1 trace 3 last value

       

      Please please include any required dim references!

       

      Thanks

        • Re: VBA to display trend trace last value in a pdi text box
          dng

          Hi Bryan,

           

          Is the idea to make the value in the text box to change if users manually change the time-range of a trend? If you use the Value symbols to display the value, the values will automatically correspond to the last value of the trend provided users change the time-scale of the entire display (instead of just the trend). If users do indeed will change the time-scale of the trend independently, you can potentially change the TimeRange for the value symbol to match that for the trend symbol via VBA.

          • Re: VBA to display trend trace last value in a pdi text box
            gachen

            Hi Bryan,

             

            You'd probably want to use the Trend.GetValue() method. Before calling the method, you will need to set the Trend.CurrentTrace value to the trace that you want the value for. For example, the code below loops through each of the traces in "Trend1" and then does something with the current value returned:

             

            Dim timestamp As Variant
            Dim status As Long
            For i = 1 To Trend1.TraceCount
                 Trend1.CurrentTrace = i
                 'Do something with Trend1.GetValue(timestamp, status)
            Next i
            
            1 of 1 people found this helpful