我正在将此代码与罗克韦尔自动化的模拟软件 Arena 一起使用。我正在尝试获取代码以从 excel 表中读取一些数据并将其分配给进入 vba 模块的实体的属性。当我运行仿真时,我得到这个 SIMAN 错误窗口:
“17035:EEVBA 实体:2
在以下块的时间 0.0 检测到运行时错误:* 6 15$ VBA:0,vba:NEXT(2$);
事件编号 0 无效:必须为正数。”
这个错误是什么意思?这是我的代码,有什么建议吗?:
Option Explicit
Public XL As Object
Public Wo As Integer
Public W_1 As Integer
Public NumContenedor As Integer
Public Sub ModelLogic_RunBeginSimulation()
Dim m As Model
Set m = ThisDocument.Model
Dim FileToOpen As String
Set XL = GetObject("", "Excel.Application")
FileToOpen = "C:\Users\A\data.xlsx"
XL.Workbooks.Open FileToOpen
End Sub
Public Sub VBA_Block_1_Fire()
Dim s As SIMAN
Set s = ThisDocument.Model.SIMAN
NumContenedor = s.EntityAttribute(s.ActiveEntity, s.SymbolNumber("NumContenedor"))
Wo = XL.Workbooks(1).Worksheets(1).Cells(NumContenedor, 4).value
W_1 = XL.Workbooks(1).Worksheets(1).Cells(NumContenedor, 5).value
s.EntityAttribute(s.ActiveEntity, s.SymbolNumber("deltaW")) = W_1 - Wo
End Sub
Public Sub ModelLogic_RunEnd()
XL.Quit
End Sub