Dynamische Onlinevariablen im Container

Dynamische Onlinevariablen im Container

Hallo,
ich bin blutiger Anfänger in VBA und versuche gerade meine ersten Gehversuche.
Ich habe einen Skript geschrieben, mit welchem ich in einer Form die Motoren im Feld steuern möchte. Der Skript funktioniert soweit, aber ich möchte das der benötigte Container für Onlinevariablen in diesem Skript erstellt wird und die benötigten Variablen bereit stellt. Danach soll der Container wieder gelöscht werden, bis zum nächsten Aufruf.
Die mir unklaren Codezeilen habe ich kommentiert.
Vielen Dank für eure Hilfe.
'Skript, welcher die Form aufruft, bei Mouseklick
Public Sub LeftClickUp_Motorsteuerung(obElem As Element)
frmMotorsteuerung.Motorsteuerung obElem
frmMotorsteuerung.Show
obElem.LeftClickUp
End Sub

'Skript in der Form "frmMotorsteuerung"
Dim strName As String
Public Sub Motorsteuerung(obElem As Element)
Dim zOLV As OnlineVariable
Dim intVariablenTxtLaenge As Integer
Dim strCharacter As String
Dim intListbox As Integer
Dim bolOff As Boolean
Dim bolHand As Boolean
Dim bolAuto As Boolean
Dim bolMotorschutz As Boolean
Dim bolSchuetz As Boolean
Dim bolStoerungFU As Boolean
Dim bolNotentriegelung As Boolean
Dim bolStoermeldungen As Boolean
Dim bolBedienfreigabe As Boolean
Dim i As Integer
i = 0
strCharacter = ""
strCharacter = Mid$(obElem.ItemVariable(0).Name, 1, 1)
Do Until strCharacter = "."
i = i + 1
strCharacter = Mid$(obElem.ItemVariable(0).Name, i, 1)
Loop
strName = Left$(obElem.ItemVariable(0).Name, i - 1)
'Erstellen des Containers für Online Variablen (wahrscheinlich falsch)
Set zOLV = thisProject.OnlineVariables.Item("ContainerMotorsteuerung")
Set zOLV = thisProject.OnlineVariables.CreateOnlineVariables("ContainerMotorsteuerung")
zOLV.Add thisProject.Variables.Item(strName + ".Listbox")
zOLV.Add thisProject.Variables.Item(strName + ".RM Störung Motorschutz")
zOLV.Add thisProject.Variables.Item(strName + ".RM Störung Schütz fehlt")
zOLV.Add thisProject.Variables.Item(strName + ".RM Störung FU")
zOLV.Add thisProject.Variables.Item(strName + ".Notentriegelung")
zOLV.Add thisProject.Variables.Item(strName + ".Störmeldungen Aktiv")
zOLV.Add thisProject.Variables.Item(strName + ".Bedienfreigabe")
zOLV.Define
frmMotorsteuerung.Caption = strName
intListbox = thisProject.Variables.Item(strName + ".Listbox").Value
bolMotorschutz = thisProject.Variables.Item(strName + ".RM Störung Motorschutz").Value
bolSchuetz = thisProject.Variables.Item(strName + ".RM Störung Schütz fehlt").Value
bolStoerungFU = thisProject.Variables.Item(strName + ".RM Störung FU").Value
bolNotentriegelung = thisProject.Variables.Item(strName + ".Notentriegelung").Value
bolStoermeldungen = thisProject.Variables.Item(strName + ".Störmeldungen Aktiv").Value
bolBedienfreigabe = thisProject.Variables.Item(strName + ".Bedienfreigabe").Value
ckbNotentriegelung.Value = bolNotentriegelung
ckbStoermeldungen.Value = bolStoermeldungen
Select Case intListbox
Case 0
tbOff.Value = True
tbHand.Value = False
tbAuto.Value = False
Case 1
tbOff.Value = False
tbHand.Value = True
tbAuto.Value = False
Case 2
tbOff.Value = False
tbHand.Value = False
tbAuto.Value = True
Case Else
tbOff.Value = False
tbHand.Value = False
tbAuto.Value = False
End Select
If bolMotorschutz = True Then
txtMotorschutz.BackColor = &HFF
Else
txtMotorschutz.BackColor = &H8000000F
End If
If bolSchuetz = True Then
txtSchuetz.BackColor = &HFF
Else
txtSchuetz.BackColor = &H8000000F
End If
If bolStoerungFU = True Then
txtStoerungFU = &HFF
Else
txtStoerungFU = &H8000000F
End If
If bolNotentriegelung = True Then
txtNotentriegelung.BackColor = &HFF
Else
txtNotentriegelung.BackColor = &H8000000F
End If
If bolBedienfreigabe = False Then
tbOff.Enabled = False
tbHand.Enabled = False
tbAuto.Enabled = False
ckbNotentriegelung.Enabled = False
Else
tbOff.Enabled = True
tbHand.Enabled = True
tbAuto.Enabled = True
ckbNotentriegelung.Enabled = True
End If
'Löschen des Containers (Richtige Stelle im Skript!?)
Set zOLV = Nothing
End Sub
Private Sub ckbNotentriegelung_Click()
If ckbNotentriegelung.Value = True Then
thisProject.Variables.Item(strName + ".Notentriegelung").Value = 1
txtNotentriegelung.BackColor = &HFF
Else
thisProject.Variables.Item(strName + ".Notentriegelung").Value = 0
txtNotentriegelung.BackColor = &H8000000F
End If
End Sub
Private Sub ckbStoermeldungen_Click()
If ckbStoermeldungen.Value = True Then
thisProject.Variables.Item(strName + ".Störmeldungen Aktiv").Value = 1
Else
thisProject.Variables.Item(strName + ".Störmeldungen Aktiv").Value = 0
End If
End Sub
Private Sub tbOff_Click()
If tbOff.Value = True Then
tbHand.Value = False
tbAuto.Value = False
thisProject.Variables.Item(strName + ".Listbox").Value = 0
End If
End Sub
Private Sub tbHand_Click()
If tbHand.Value = True Then
tbOff.Value = False
tbAuto.Value = False
thisProject.Variables.Item(strName + ".Listbox").Value = 1
End If
End Sub
Private Sub tbAuto_Click()
If tbAuto.Value = True Then
tbOff.Value = False
tbHand.Value = False
thisProject.Variables.Item(strName + ".Listbox").Value = 2
End If
End Sub

This is a migrated post! Originally posted on 19.08.2008 by user bzoller. 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