示例:读取标签属性

本示例阐述了如何读取标签属性值。第一个子程序创建了 TagGroup 对象,并对其添加了标签并激活 TagGroup。第二个子程序读取 TagGroup 中标签的三个属性值。
Dim WithEvents oGroup As TagGroup Sub SetUpTagGroup() 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 oGroup.Add "System\Second" oGroup.Add "System\Minute" oGroup.Active = True End If End Sub Sub ShowTagProperties() On Error GoTo ErrHandler Dim oTag As Tag Dim sDescription As String Dim vMin As Variant Dim vMax As Variant If Not oGroup Is Nothing Then Set oTag = oGroup.Item("System\Second") sDescription = oTag.GetPropertyValue(tagPropIdDescription) vMin = oTag.GetPropertyValue(tagPropIdLowEU) vMax = oTag.GetPropertyValue(tagPropIdHighEU) MsgBox "Tag Name: " & oTag.Name & vbCrLf & _ "Tag Min: " & vMin & vbCrLf & _ "Tag Max: " & vMax & vbCrLf & _ "Tag Description: " & sDescription End If Exit Sub ErrHandler: Select Case Err.Number Case tagErrorPropertyNotSupported: MsgBox "Tag does not support property. Error: " & Err.Description Case tagErrorOperationFailed: MsgBox "Failed to read property from tag. Error: " & Err.Description End Select End Sub
提供反馈
对本文档有问题或反馈吗? 请在这里提交您的反馈
Normal