我是说用VB编程,PLC是西门子s7-200,似乎OPC服务器的名字是唯一的。下面是西门子OPC通信的例子,明月兄能否给个例子?
Set MyOPCServer = New OPCServer ‘ Create OPCServer Object
Call MyOPCServer.Connect("S7200.OPCServer") ‘ connect to OPC Server
‘ PLCAddress = "2"
Dim CID As Long ‘ CancelID, servergenerierter Wert, mit dem die Transaktion identifiziert
‘add groups
Set MyOPCGroups = MyOPCServer.OPCGroups ‘ Get OPCGroups Collection Object from MyOPCServer
‘ Set Default Properties for Group Collection
‘ These Properties are used to set the Properies for new Groups
MyOPCGroups.DefaultGroupIsActive = 200 ‘ Set Default Group renew Rate to 500 ms
MyOPCGroups.DefaultGroupIsActive = False ‘ Set Default Group Active State to Inactive
Set GroupWrite = MyOPCGroups.Add("GWrit") ‘ Add a new Group to the Group Collection
‘ Set Group Properties
GroupWrite.IsSubscribed = True ‘ Enable Callbacks
GroupWrite.IsActive = True
Set WritItems = GroupWrite.OPCItems ‘ Get OPCItems Collection Object from MyOPCServer