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