VBA Tag monitoring in RSView SE

finski2

Member
Join Date
May 2007
Location
Milwaukee
Posts
21
Hi,

I am working on a graphic that will fill a ListView ActiveX control based on a value of a tag. There are 118 tanks that I am looking at, and if the value of a tag equals 7, I want to put it in the list.

I have the "display_animationstart" working, and a "refresh" button with similar script working. My problem is gettubg the "ptagGroup_Change" subroutine to scan automatically. I have gotten this to work for other displays without a problem. I can't find out what I am missing.

Dim WithEvents ptagGroup As TagGroup
--------------------------------------
Private Sub Display_AnimationStart()

Set ptagGroup = CreateTagGroup(Me.AreaName)
ptagGroup.Add("tag1")
.
.
.
ptagGroup.Add("tag118")
ptagGroup.Active = True
if ptagGroup("tag1").Value = 7 Then
ListView1.AddItem("Tank 1")
end if

Exit Sub
End Sub
--------------------------------------
Private Sub ptagGroup_Change(ByVal TagName As StringList)

If ptagGroup("tag1").Value=7 Then
ListView1.AddItem("Tank 1")
EndIf

End Sub
 
if ptagGroup("tag1").Value = 7 Then
ListView1.AddItem("Tank 1")
end if


Is there part of your code missing?

If seems to me you will be needing a for next loop here.

'''''''''''''''''
Private Sub ptagGroup_Change(ByVal TagName As StringList)

If ptagGroup("tag1").Value=7 Then
ListView1.AddItem("Tank 1")
EndIf

End Sub


Here you are passing the variable TagName but not using it.
Should it not be If ptagGroup("TagName").Value=7 Then
 
Yeah, there is some code missing above. But it is not relevent to my question, so I excluded it.

(Not so) Bassially, I am trying to figure out why, after declaring the tag group "with events" then creating and activating the tag group in displayanimation_start() routine, I am not calling the subroutine ptagGroup_Change(ByVal TagNames As StringList)

The identical script runs perfect when I have it run when a button is clicked, so I know the code within the subroutine is fine, I am just not able to call the subroutine on a change of tag value within the tag group.
 
I added a numeric field (NumericDisplay1) and added in the VB Code as follows. This was tested on a 505. I also had a ListViewCtrl1 on the display screen.

In my example I was looking at the value of N7:0 to change.
If it did I cleared and updated the ListView.

Private Sub NumericDisplay1_Change()
Dim column_header As ColumnHeader
Dim list_item As ListItem
Dim i As Integer
ListViewCtrl1.ListItems.Clear

Dim oGroup As TagGroup
Dim TagName As String
On Error Resume Next
Err.Clear
If oGroup Is Nothing Then
Set oGroup = Application.CreateTagGroup(Me.AreaName, 500)
If Err.Number Then
LogDiagnosticsMessage "Error creating TagGroup. Error: " & Err.Description, ftDiagSeverityError

Exit Sub
End If
End If

For i = 0 To 9
TagName = "::[gas]N7:" + LTrim(Str(i)) + ""
oGroup.Add TagName
Next i
oGroup.Active = True

For i = 0 To 9

If oGroup.Item(i).Value = 7 Then 'Test to see if value is 7
Set list_item = ListViewCtrl1.ListItems.Add(, , oGroup.Item(i).Name & ":" & oGroup.Item(i).Value)
End If

Next
End Sub
 
yeah, I was needing mine to scan the entire tag group of 118 tags, so the numeric display wouldn't work.

however, for reasons unknown to me, when I showed up this morning and tested the code again, it worked. I did not change anything other than a restart the computer. The magic cure to 90% of RSView issues.

Thanks for your help though!
 

Similar Topics

Hi, I am working on a graphic that will fill a ListView ActiveX control based on a value of a tag. There are 118 tanks that I am looking at, and...
Replies
0
Views
3,972
Hi, how can i use a defined Tag in HMI Tags (for exampele dintTag ) in VBA code by a display. i am using FactoryTalk SE thanx
Replies
1
Views
2,225
I am running XLReporter (v14) and FTView SE (v11: Distributed Server) on the same computer (Server 2016 Standard). XLReporter is reading data from...
Replies
1
Views
2,741
Hi: I am trying to read an array of 100 elements from ControlLogix to FTView SE, using VBA. I need to asign all the elements to another array tag...
Replies
6
Views
2,590
Hi there, I have been looking in the forums for this and I saw a couple of examples but I still don't understand very well how to create a VBA...
Replies
4
Views
8,980
Back
Top Bottom