2
I’m having trouble with input and output data between the simulation of Rockwell Arena software and their native Visual Basic. Basically what I want is to receive simulation data for Visual Basic, process it and return the result to the simulation. I started with something very simple, I’m trying to make the variable "Target" always be 5, but using VBA, so every time an entity enters the VBA block, this variable must be set to 5, then go through the decision block and go to "Dispose 5"as shown in the attached image.
I wrote that 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 on the line S.VariableArrayValue(S.SymbolNumber("Destino")) = 5
the following error message appears:
"Run-time error '91':
Object variable or with block variable not set"
Can you add the full code? Make sure you are being called the method
ModelLogic_RunBeginSimulation
before theVBA_Block_1_Fire
.– davidterra
This is already the complete code, I believe that the Arena already takes care of calling the routines in the correct order. Another thing, "Destination" is the variable that controls the block decides, had not made it clear when I asked the question.
– Renan Ávila
By the error message it seems that
S
was not created, ie received anew
. Add a Breakpoint run the code step by step and see ifS
is notIs Nothing
.– davidterra
I put some IF’s and found that the S is not Is Nothing
– Renan Ávila