Mohammad

The SelectedSymbols Collection

Discussion created by Mohammad on Oct 8, 2009
Latest reply on Oct 9, 2009 by spilon

Hello

 

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.

Sub GetData()

    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."
        End
    ElseIf ThisDisplay.SelectedSymbols.Item(1).Type <> PBObjLib.pbSymbolTrend Then
        MsgBox " Please select A trend."
        End
    End If

    Set trendproxy = ThisDisplay.SelectedSymbols.Item(1)

    trendproxy.CurrentTrace = trendproxy.TraceCount

    pointcount = trendproxy.TraceValuesCount

    ThisDisplay.ListBox1.Clear
    ThisDisplay.ListBox2.Clear

    For i = 1 To pointcount

        value = trendproxy.GetTraceValue(i, time, restart)

        ThisDisplay.ListBox1.AddItem (time)
        ThisDisplay.ListBox2.AddItem (Format(value, "0.00"))

    Next i

End Sub

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.

 

Thanks

Outcomes