VB code to write tag value into RSViewStudio

Paglia

Member
Join Date
Mar 2007
Location
Milan
Posts
3
I've devoleped a VB application for retrieve data from an Access database and now I wont write this values to some tag into my RSView studio stand alone application.

I've tried with a reference to "DisplayClient" and then to create a TagGroup object and then add a tag to this object, but doesn't work...

Can you help me????

Thank you, Virginio
 
I've found the solution, If someone is interested:

Sub SetUpTagGroup()
Dim oCl As Application
On Error Resume Next

Err.Clear

If oCl Is Nothing Then
Set oCl = displayclient.Application

End If

If oGroup Is Nothing Then

Set oGroup = oCl.CreateTagGroup("/", 500)

If Err.Number Then

LogDiagnosticsMessage "Error creating TagGroup. Error: " & Err.Description, ftDiagSeverityError

Exit Sub

End If

oGroup.Add "TEST_TAG"

oGroup.Active = True

End If

End Sub


Sub SetTagValue()

On Error Resume Next

Dim oTag As Tag

If Not oGroup Is Nothing Then


Set oTag = oGroup.Item("TEST_TAG")

Err.Clear

oTag.Value = 10


' Test the Error number for the result.

Select Case Err.Number


Case 0:

' Write completed successfully... log a message

LogDiagnosticsMessage "Write to tag " & oTag.Name & " was successful."


Case tagErrorReadOnlyAccess:

MsgBox "Unable to write tag value. Client is read-only."


Case tagErrorWriteValue:

If oTag.LastErrorNumber = tagErrorInvalidSecurity Then

MsgBox "Unable to write tag value. The current user does not have security rights."

Else

MsgBox "Error writing tag value. Error: " & oTag.LastErrorString

End If


Case tagErrorOperationFailed:

MsgBox "Failed to write to tag. Error: " & Err.Description

End Select

End If

End Sub
 

Similar Topics

Hello Friends.... I am trying to read & write the PLC tags through VBA code but not getting correct syntax, i m using FTView SE 6.0 Your help will...
Replies
10
Views
8,250
Does anyone know what Key Code does? This is linked to the button called "Alarm Ack." I searched for device FFB4 in the code but couldn't find...
Replies
5
Views
2,106
Hi, complete novice here. GXDeveloper: I work in a test facility controlled by Q-series PLC. I want to do some self-training on ladder logic...
Replies
22
Views
4,137
Good Morning everyone, I need your help to rewrite the code or better way to write the code because honestly I didn't like how the code is right...
Replies
27
Views
7,968
Need good example/sample of aoi RSLogix5000 code to read&write through RS232 port on Need good example/sample of aoi RSLogix5000 code to...
Replies
0
Views
1,841
Back
Top Bottom