RSview中内嵌得vb语言,怎么样给标签赋值??? 点击:1145 | 回复:2



自控小学生

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 0回
  • 年度积分:0
  • 历史总积分:56
  • 注册:2006年4月04日
发表于:2006-08-14 13:05:00
楼主
小弟近来用RSview做个画面,想用其内嵌得vb给标签(内部/外部)赋值,但是怎么写都赋不进去,估计是格式不对,还请各位大哥给个例子,多谢了?内部标签例如:abc



xiezm

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 125回
  • 年度积分:0
  • 历史总积分:193
  • 注册:2003年3月07日
发表于:2006-08-21 17:40:00
1楼
你可以在VBA中的帮助里面找到例子.在VBA的IDE中,按F1帮助就可以出来相应的帮助文件.

xiezm

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 125回
  • 年度积分:0
  • 历史总积分:193
  • 注册:2003年3月07日
发表于:2006-08-21 17:41:00
2楼
下面是VBA自带的例子(对Tag进行写操作),你可以参考一下:

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 SetTagValue()

    On Error Resume Next

    Dim oTag As Tag

    If Not oGroup Is Nothing Then

    

        Set oTag = oGroup.Item("System\Second")

        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

热门招聘
相关主题

官方公众号

智造工程师