cdmahong
2015-01-08 06:59
采纳率: 33.3%
浏览 2.6k
已采纳

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

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • save4me 2015-01-08 15:24
    已采纳

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

    已采纳该答案
    打赏 评论
  • threenewbee 2015-01-08 08:01

    Dim lHandle As System.Array
    看看

    打赏 评论

相关推荐 更多相似问题