OPC-无法将类型为“System.Int32”的对象强制转换为类型“System.Array”

OPC-无法将类型为“System.Int32”的对象强制转换为类型“System.Array”

问题描述:

图片说明

在用VB.NET编写OPC读写西门子S7400程序时候,碰到以上句柄问题,请问该问题如何解决?

Public Shared MyItemServerHandles2 As System.Array

Private Sub PLC_AsyncWrite(ByVal NumItemsW As Integer, ByRef ItemValuesW() As System.Object, ByRef MyErrors As System.Array)
Dim lHandle(U_NUMITEMS) As System.Array
Dim i As Integer
If MyGroup2 Is Nothing Then
Exit Sub
End If
If MyGroup2.OPCItems.Count > 0 Then
lTransID_Rd2 = lTransID_Rd2 + 1
For i = 1 To 30
lHandle(i) = MyItemServerHandles2(NumItemsW)

MyGroup2.AsyncWrite(1, lHandle(i), ItemValuesW,
MyErrors, lTransID_Rd2, lCancelID_Rd2)
Next
End If
End Sub

参考谈谈VB.NET数组的使用中VB.NET数组的声明,应该是
Dim lHandle(U_NUMITEMS) As Integer

Dim lHandle As System.Array
看看