本人第一次接触OPC,希望在VB 2005中使用OPC,
我在自己的电脑上安装了 KEPServerEX? V4.105之后, 在同一电脑上的VB.NET里将 C:\Windows\System32\OPCDAAUTO.DLL引用,该电脑上没有PLC设备.
写入了以下代码:
Imports OPCAutomation
‘定义OPC需要使用到的,与OPC Server连接访问的数组变量,存放OPC Server当中的各种类型数据
Dim WithEvents AnOPCServer As OPCServer
Dim WithEvents ConnectedOPCServer As OPCServer
Dim ConnectedServerGroup As OPCGroups
Dim WithEvents ConnectedGroup As OPCGroup
Dim OPCItemCollection As OPCItems
Dim ItemCount As Long
Dim OPCItemIDs(10) As String
Dim ItemServerHandles() As Long
Dim ItemServerErrors() As Long
Dim ClientHandles(10) As Long
‘然后开始连接OPC Server
Dim ConnectedServerName As String
‘Create a new OPC Server object
ConnectedOPCServer = New OPCServer
‘Load the selected server name to start the interface
ConnectedServerName = "KEPServerEX"??? ‘"Developer - Enter Your OPC Server Name Here in quotes"
ConnectedOPCServer.Connect(ConnectedServerName)
最后一句 Connect 始终是报错,
不知道是怎么回事? 请各位大侠不吝赐教
?
?
?