qmhn8726
qmhn8726
关注数: 0
粉丝数: 5
发帖数: 180
关注贴吧数: 16
VB程序运行时,报错,找不出,希望高手帮帮忙! 本人找不出,希望高手能帮帮忙其中一段程序 On Error GoTo ErrorHandler3 Dim i As Long Dim ErrorFlag As Boolean Dim ItemObj As OPCItem Dim ItemIDs(30) As String Dim ItemClientHandles(30) As Long Dim Errors() As Long ' Array for returned Item related errors ErrorFlag = False Set MyItems = MyGroup.OPCItems ' Get OPCItems Collection Object from MyOPCServer ' Initialize the [IN] parameters for the Add Items call ' ItemIDs -> ItemIDs of the Items to add ' ItemClientHandles -> Client defined handles for the Items. The Server sends these handles in the Callbacks ItemIDs(1) = "2,vw0,word" ItemIDs(2) = "2,vw2,word" ItemIDs(3) = "2,vw4,word" ItemIDs(4) = "2,vw6,word" ItemIDs(5) = "2,vw8,word" ItemIDs(6) = "2,vw10,word" ItemIDs(7) = "2,vw12,word" ItemIDs(8) = "2,vw14,word" ItemIDs(9) = "2,vw16,word" ItemIDs(10) = "2,vw18,word" ItemIDs(11) = "2,vw20,word" ItemIDs(12) = "2,vw22,word" ItemIDs(13) = "2,vw24,word" ItemIDs(14) = "2,vw26,word" ItemIDs(15) = "2,vw28,word" ItemIDs(16) = "2,vw30,word" ItemIDs(17) = "2,vw32,word" ItemIDs(18) = "2,vw34,word" ItemIDs(19) = "2,vw36,word" ItemIDs(20) = "2,vw38,word" ItemIDs(21) = "2,vw40,word" ItemIDs(22) = "2,vw42,word" ItemIDs(23) = "2,vw44,word" ItemIDs(24) = "2,vw100,word" ItemIDs(25) = "2,vw102,word" ItemIDs(26) = "2,vw104,word" ItemIDs(27) = "2,vw106,word" ItemIDs(28) = "2,vw108,word" ItemIDs(29) = "2,vw110,word" ItemIDs(30) = "2,vw112,word" For i = 1 To 30 ItemClientHandles(i) = i Next ' [OUT] parameters are ' ItemServerHandles -> Server defined handles for the Items. The client must use these handles for all Read/Write calls ' Errors -> Item related errors ' Add Items to the Group Call MyItems.AddItems(30, ItemIDs, ItemClientHandles, MyItemServerHandles, Errors) ' Check Item Errors For i = 1 To 30 If Not Errors(i) = 0 Then MsgBox "Item " + Str$(i) + " FAILED. Error Code = " + Str$(Errors (i)), vbCritical ErrorFlag = True End If Next ' Continue only if all Items SUCCEEDED If ErrorFlag Then Dim RemoveErrors() As Long Dim RemoveHandles(1) As Long ' Remove Succeede Items For i = 1 To 30 If Errors(i) = 0 Then RemoveHandles(1) = MyItemServerHandles(i) Call MyItems.Remove(1, RemoveHandles, RemoveErrors) End If Next End If Exit Sub ErrorHandler1: MsgBox Err.Description + Chr(13) + "Connecting to OPC Server", vbCritical, "ERROR" Exit Sub ErrorHandler2: MsgBox Err.Description + Chr(13) + "Adding a Group to OPC Server", vbCritical, "ERROR" Exit Sub ErrorHandler3: MsgBox Err.Description + Chr(13) + "Adding Items to the Group", vbCritical, "ERROR" End Sub
1
下一页