Funktionsausführung bei VariableChange von Containern

Funktionsausführung bei VariableChange von Containern

Hallo,
ich habe ein Projekt in dem ich einen Container angelegt habe und bei bestimmten Variablen eine Funktion ausführen will wenn diese sich ändern.
Soweit funktioniert es auch, dass die Funktion bei den Variablen ausgeführt wird, allerdings funktioniert die Zuweisung in der Funktion nicht (bzw nicht immer.. ab und zu hat es schon geklappt, aber warum nicht immer ist mir ein Rätsel)
VBA Code:

Private Sub Project_Active()
Dim Index1 As Integer
Dim Index2 As Integer
'##### STARTRUTINE DER RUNTIME #####
Set Allg_Container = thisProject.OnlineVariables.Item("allgemein")

If Allg_Container Is Nothing Then

Set Allg_Container = thisProject.OnlineVariables.CreateOnlineVariables("allgemein")

For Index1 = 1 To 849
Allg_Container.Add "CarData.Database[" & Index1 & "].CarData.ID_Nr"
Allg_Container.Add "CarData.Database[" & Index1 & "].CarData.AdditionalInfo.Res_0_3"
Allg_Container.Add "CarData.Database[" & Index1 & "].CarData.AdditionalInfo.Res_0_4"
Next

For Index1 = 1 To 4
For Index2 = 1 To 180
Allg_Container.Add "LaneData.Lane[" & Index1 & "].ShelfNr[" & Index2 & "].IdentNr"
Allg_Container.Add "LaneData.Lane[" & Index1 & "].ShelfNr[" & Index2 & "].Found"
Allg_Container.Add "LaneData.Lane[" & Index1 & "].ShelfNr[" & Index2 & "].Blocked"
Allg_Container.Add "LaneData.Lane[" & Index1 & "].ShelfNr[" & Index2 & "].PLEINLAG_OK"
Allg_Container.Add "LaneData.Lane[" & Index1 & "].ShelfNr[" & Index2 & "].RecordNr"
Next
Next

End If

Allg_Container.Define

Private Sub Allg_Container_VariableChange(ByVal obVar As IVariable)
Dim vValue As Variant
Dim i As Integer
Dim Shelf As Integer
Dim Lane As Integer
Dim RecID As Integer
vValue = obVar.Value
If IsError(vValue) Then Exit Sub
For Lane = 1 To 4
For Shelf = 1 To 180
If obVar.Name = "LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].RecordNr" Then
RecID = thisProject.Variables.Item(obVar.Name).Value
UpdateShelfPic RecID, Lane, Shelf
End If
Next
Next
End Sub

Soweit ich das sehe funktioniert der obige Code und du Funktion UpdateShelfPic wird aufgerufen und die Parameter richtig übergeben
in der Funktion klappt allerdings dann die Zuweisung der Variablenwerte nicht mehr, aber warum ist mir ein Rätsel.. die Variablen sind im Container und Online, Verbindung zur SPS steht:
VBA Code:

Public Sub UpdateShelfPic(RecID As Integer, Lane As Integer, Shelf As Integer)
Dim EinlagDoneVar
Dim EinlagBlockVar
Dim IdentVar
Dim EinlagDone As Boolean
Dim EinlagBlock As Boolean
Dim IdentNr As String
'On Error GoTo EndErr
If RecID > 0 Then
IdentVar = "CarData.Database[" & RecID & "].CarData.ID_Nr"
EinlagDoneVar = "CarData.Database[" & RecID & "].CarData.AdditionalInfo.Res_0_3"
EinlagBlockVar = "CarData.Database[" & RecID & "].CarData.AdditionalInfo.Res_0_4"


If thisProject.Variables.Item(EinlagDone).IsOnline Then
EinlagDone = thisProject.Variables.Item(EinlagDoneVar).Value
thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].PLEINLAG_OK").Value = EinlagDone
End If

If thisProject.Variables.Item(EinlagBlock).IsOnline Then
EinlagBlock = thisProject.Variables.Item(EinlagBlockVar).Value
thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].Blocked").Value = EinlagBlock
End If

If thisProject.Variables.Item(IdentVar).IsOnline Then
IdentNr = thisProject.Variables.Item(IdentVar).Value
thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].IdentNr").Value = IdentNr
End If
Else

thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].IdentNr").Value = " "
thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].PLEINLAG_OK").Value = False
thisProject.Variables.Item("LaneData.Lane[" & Lane & "].ShelfNr[" & Shelf & "].Blocked").Value = False
End If
'EndErr:
End Sub

Hat jemand eine Idee oder sieht wo das Problem ist? :confused:

This is a migrated post! Originally posted on 13.11.2014 by user thesilver. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com