I am following the online course for PI Advanced Scripting for ProcessBook and I have a minor issue with one the scripts in the course.
The section that I am working on is The Selected Symbols Collection
I wrote the following program which is pretty similar to the online course but it does not give me the right answer.
Dim i As Long
Dim time As Variant
Dim value As Variant
Dim pointcount As Long
Dim restart As Long
Dim trendproxy As PBsymlib.Trend
If ThisDisplay.SelectedSymbols.Count = 0 Then
MsgBox "Please select a trend."
ElseIf ThisDisplay.SelectedSymbols.Item(1).Type <> PBObjLib.pbSymbolTrend Then
MsgBox " Please select A trend."
Set trendproxy = ThisDisplay.SelectedSymbols.Item(1)
trendproxy.CurrentTrace = trendproxy.TraceCount
pointcount = trendproxy.TraceValuesCount
For i = 1 To pointcount
value = trendproxy.GetTraceValue(i, time, restart)
ThisDisplay.ListBox2.AddItem (Format(value, "0.00"))
The program just gives me the message to select the trend and the second message. I select the trends and press the button but still get the "Please select A trend" message.
The sequence I did was building three trends , then list boxes, then VBE , then create a button and connect it to the macro name which is the name of my VB sub.