The goal of this post is to fine how a VB6 application using the PI ActiveView ActiveX can modify the trend property, espicially to remove the tag name and server name from the trend.
The following code is working fine when executed directly in VBA in PI ProcessBook to toggle between On and Off the tagname and server name display.
Now, in a VB6 application, the PI ActiveView ActiveX has been added to the display. From the VB6 code, we can build the trend, that is to had a trace, modifiy the trend title or modify the time scale. In the same way as discribed above, we are also trying to remove the server name and tag name in the single trend of the embedded display. Here is the code example from VB6:
Private Sub CommandButton3_Click() Dim MyTrend As Trend Set MyTrend = Application.ActiveDisplay.Symbols(1) Dim aFormat As TrendFormat Set aFormat = MyTrend.GetFormat aFormat.ShowTagName = Not (aFormat.ShowTagName) aFormat.ShowServerName = Not (aFormat.ShowServerName) MyTrend.SetFormat aFormat Set aFormat = Nothing End Sub
In this last example in VB6, the code is executed without any error message. The set format is not being applied to the trend but the trend title is changed and the start and end time is updated.
Private Sub Command1_Click() Dim MyTrend As Trend Dim aFormat As TrendFormat ' Get the Trend - Single object from the PB Display Set MyTrend = Pbd1.Display.Symbols(1) Set aFormat = MyTrend.GetFormat aFormat.ShowTagName = Not (aFormat.ShowTagName) aFormat.ShowServerName = Not (aFormat.ShowServerName) MyTrend.SetFormat aFormat ' Test Change Trend Title MyTrend.TrendTitle = CStr(Second(Now)) ' Test Change Trend Time Range MyTrend.SetStartAndEndTime "*-1h", "*" End Sub
Any help on how we could get this code to toggle between On/Off the server and tag names will be greatly appreciated.