Input and output in Arena's Visual Basic
I'm having trouble with data input and output between Arena Rockwell software Simulation and their native Visual Basic itself. Basically what I want is to receive data from the simulation to Visual Basic, process it and return the result to the simulation. I started with something pretty simple, I'm trying to make the "destination" variable always be 5, but using VBA, so every time an entity enters the VBA block, this variable should be set to 5, then go through the decision block and go to The "Dispose 5", as shown in the attached image.
I wrote this code
Option Explicit
Dim m As Arena.Model
Dim S As Arena.SIMAN
Private Sub ModelLogic_RunBeginSimulation()
Set m = ThisDocument.Model
Set S = m.SIMAN
End Sub
Private Sub VBA_Block_1_Fire()
Dim Destino As Integer
S.VariableArrayValue(S.SymbolNumber("Destino")) = 5
End Sub
But in line S.VariableArrayValue(S.SymbolNumber("Destino")) = 5
the following error message appears:
"Run-time error '91':
Object variable or with block variable not set"
1 answers
With the help of the channel guy named "Fayad" I managed to find a solution, however using other functions, and the code looked like this:
Option Explicit
Dim m As Arena.Model
Dim s As Arena.SIMAN
Private Sub ModelLogic_RunBeginSimulation()
Set m = ThisDocument.Model
Set s = m.SIMAN
End Sub
Private Sub VBA_Block_1_Fire()
Dim s As SIMAN
Set s = ThisDocument.Model.SIMAN
s.EntityAttribute(s.ActiveEntity, s.SymbolNumber("Destino")) = 5
End Sub