注册 登录
编程论坛 VB6论坛

请教VB通过OPC连接WinCC的问题

shangcq 发布于 2013-08-17 10:28, 563 次点击
下面这段代码显示能连接上,但是plcVal()数组中的值是空值,请高手帮忙指导一下,谢谢。

Option Explicit

Option Base 1

Const ServerName = "OPCServer.WinCC"

Const NodeName = "QQXWIMEKRUOT2ZT"

Private objServer As OPCServer   '定义OPC服务器

Private objGroup As OPCGroup   '定义OPC 服务器中的组

Private objGroups As OPCGroups

Private objItems As OPCItems  '定义OPC 服务器中的项目名

 

Dim StrItemIDs(10) As String

Dim ClientHandles(6) As Long

Dim Serverhandles() As Long

Dim i As Integer

Dim DataType(1000) As Integer

Dim errors() As Long

Dim accpath(1000) As String

Private Sub Command1_Click()
Dim plcVal() As Variant
Dim OPCCache As Integer

objGroup.SyncRead OPCCache, 3, Serverhandles, plcVal, errors


Text1.Text = plcVal(1)

Text2.Text = plcVal(2)

Text3.Text = plcVal(3)

End Sub
0 回复
1