Showing results 1 to 3 of 3

Thread: Variables association error in child project

  1. #1
    Join Date
    19.05.2010
    Posts
    17

    Default Variables association error in child project

    I'm working with Zenon 6.51 SP0 Build 0.
    In the Editor I have a tree structure composed of a parent project and three children projects.
    I created a wizard to automatically create variables when a symbol is dragged into a graphic page.
    My wizard is composed of a window where I can insert the variable name, the project where I want the variables to be created (in the father or a son), data type etc. (See attachment)
    Finally, the wizard allows you to associate variables created with the properties of my symbol.
    The symbol is present in the parent project and the problem arises when I want to create variables in a child project: the variables are created correctly, but they are not associated with the properties of my symbol.
    This does not happen if the variables are created in the parent project.
    Here is the code of my function:
    Private Sub pbOk_Click()
        On Error GoTo Error
        
        Dim newNormalVar As Variable
        Dim newVeryLowVar As Variable
        Dim newLowVar As Variable
        Dim newHighVar As Variable
        Dim newOverflowVar As Variable
        Dim newDisableVar As Variable
        Dim newVeryLowAlarmsVar As Variable
        Dim newLowAlarmsVar As Variable
        Dim newHighAlarmsVar As Variable
        Dim newOverflowAlarmsVar As Variable
        Dim newInvalidVar As Variable
        Dim newSimuVar As Variable
        Dim vProps As Variant
        Dim it As Integer
        Dim strProp() As String
        
        'Check if variable name already exists
        Dim found As Boolean
        Dim nIndex As Long
        For nIndex = 0 To MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Count - 1
            If MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(nIndex).name = tbVarName.Text & "_Normal" Then
                found = True
                Exit For
            End If
        Next nIndex
        
        Dim varName As String
        varName = tbVarName.Text
        
        'If variable name doesn't exist create variables
        If Not found Then
            Dim varDriver As Driver
            Set varDriver = MyWorkspace.Application.Projects.Item(cbProjects.Text).Drivers.Item(cbDriver.Text)
            
            Dim varChannelType As Integer
            varChannelType = GetChannelType(cbObjectType.Text)
            
            Dim varDataType As VarType
            Set varDataType = MyWorkspace.Application.Projects.Item(cbProjects.Text).VarTypes.Item("BOOL")
            
            Dim disableName As String
            disableName = varName & "_Enable"
            
            Dim cmdName As String
            cmdName = varName & "_CMD"
            
            Dim remName As String
            remName = varName & "_REM"
            
            Dim simuName As String
            simuName = varName & "_Simulation"
            
            Dim internalDriver As Driver
            Set internalDriver = MyWorkspace.Application.Projects.Item(cbProjects.Text).Drivers.Item("Variabili Interne")
            
            Dim mathDriver As Driver
            Set mathDriver = MyWorkspace.Application.Projects.Item(cbProjects.Text).Drivers.Item("Variabili matematiche")
            
            Dim boolVarType As VarType
            Set boolVarType = MyWorkspace.Application.Projects.Item(cbProjects.Text).VarTypes.Item("BOOL")
            
            Dim nChannelType As Integer
            nChannelType = tpVirtuellOnlBerechnen 'this is equal to: obKanaltyp = 17
            
            Dim internChannelType As Integer
            internChannelType = GetChannelType("Internal variable")
            
            Dim invIdx As Integer
            Dim t As Boolean
            Dim typeFound As Boolean
            Dim nClassCurrentAmount As Integer
            Dim nLastColor As Double
            Dim strLastClassName As String
            
            Set newNormalVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(varName & "_Normal", varDriver, varChannelType, varDataType)
            newNormalVar.Tagname = varName
            
            Dim invalidName As String
            invalidName = varName & "_Invalid"
            Set newInvalidVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(invalidName, mathDriver, nChannelType, varDataType)
            
            If ckbVeryLow.value = True Then
                Set newVeryLowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(varName & "_VeryLow", varDriver, varChannelType, varDataType)
                newVeryLowVar.Tagname = varName
                Dim veryLowAlarmName As String
                veryLowAlarmName = varName & "_VeryLow_Alarm"
                MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.DeleteVar (veryLowAlarmName)
                Set newVeryLowAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(veryLowAlarmName, mathDriver, nChannelType, varDataType)
                newVeryLowAlarmsVar.Tagname = varName
                newVeryLowAlarmsVar.DynProperties("AreaName") = cbAlarmArea.Text
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newVeryLowAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newVeryLowAlarmsVar.DynProperties("MathInfo[0].SourceVars[0].Title") = newVeryLowVar
                newVeryLowAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newVeryLowAlarmsVar.DynProperties("MathInfo[0].SourceVars[1].Title") = newDisableVar
    
                'define type of formular (6208 = Statistik)
                newVeryLowAlarmsVar.DynProperties("MathInfo[0].Type") = 6208
                'insert formular
                newVeryLowAlarmsVar.DynProperties("MathInfo[0].Formula") = "X02 AND NOT(X01)"
                
                newVeryLowAlarmsVar.EdLimitItem(0).Text = "VERY LOW LEVEL OFF"
                newVeryLowAlarmsVar.EdLimitItem(0).Cel = True
                newVeryLowAlarmsVar.EdLimitItem(0).DynProperties("GroupName") = m_obDriver.Identification
                newVeryLowAlarmsVar.EdLimitItem(0).DynProperties("Color") = 65280 '00FF00 Verde
                
                newVeryLowAlarmsVar.EdLimitItem(1).Alarm = True
                newVeryLowAlarmsVar.EdLimitItem(1).Text = "VERY LOW LEVEL ON"
                newVeryLowAlarmsVar.EdLimitItem(1).Cel = True
                newVeryLowAlarmsVar.EdLimitItem(1).DynProperties("GroupName") = m_obDriver.Identification
                newVeryLowAlarmsVar.EdLimitItem(1).DynProperties("Color") = 255 'FF0000 Rosso
                newVeryLowAlarmsVar.EdLimitItem(1).Blinking = True
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newInvalidVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newInvalidVar.DynProperties("MathInfo[0].SourceVars[" & invIdx & "].Title") = newVeryLowVar
                invIdx = invIdx + 1
            End If
            
            If ckbLow.value = True Then
                Set newLowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(varName & "_Low", varDriver, varChannelType, varDataType)
                newLowVar.Tagname = varName
                Dim lowAlarmName As String
                lowAlarmName = varName & "_Low_Alarm"
                MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.DeleteVar (lowAlarmName)
                Set newLowAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(lowAlarmName, mathDriver, nChannelType, varDataType)
                newLowAlarmsVar.Tagname = varName
                newLowAlarmsVar.DynProperties("AreaName") = cbAlarmArea.Text
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newLowAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newLowAlarmsVar.DynProperties("MathInfo[0].SourceVars[0].Title") = newLowVar
                newLowAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newLowAlarmsVar.DynProperties("MathInfo[0].SourceVars[1].Title") = newDisableVar
    
                'define type of formular (6208 = Statistik)
                newLowAlarmsVar.DynProperties("MathInfo[0].Type") = 6208
                'insert formular
                newLowAlarmsVar.DynProperties("MathInfo[0].Formula") = "X02 AND NOT(X01)"
                
                newLowAlarmsVar.EdLimitItem(0).Text = "LOW LEVEL OFF"
                newLowAlarmsVar.EdLimitItem(0).Cel = True
                newLowAlarmsVar.EdLimitItem(0).DynProperties("GroupName") = m_obDriver.Identification
                newLowAlarmsVar.EdLimitItem(0).DynProperties("Color") = 65280 '00FF00 Verde
                
                newLowAlarmsVar.EdLimitItem(1).Alarm = True
                newLowAlarmsVar.EdLimitItem(1).Text = "LOW LEVEL ON"
                newLowAlarmsVar.EdLimitItem(1).Cel = True
                newLowAlarmsVar.EdLimitItem(1).DynProperties("GroupName") = m_obDriver.Identification
                newLowAlarmsVar.EdLimitItem(1).DynProperties("Color") = 255 'FF0000 Rosso
                newLowAlarmsVar.EdLimitItem(1).Blinking = True
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newInvalidVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newInvalidVar.DynProperties("MathInfo[0].SourceVars[" & invIdx & "].Title") = newLowVar
                invIdx = invIdx + 1
            End If
            
            'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
            newInvalidVar.CreateDynProperty ("MathInfo[0].SourceVars")
            newInvalidVar.DynProperties("MathInfo[0].SourceVars[" & invIdx & "].Title") = newNormalVar
            invIdx = invIdx + 1
            
            If ckbHigh.value = True Then
                Set newHighVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(varName & "_High", varDriver, varChannelType, varDataType)
                newHighVar.Tagname = varName
                Dim highAlarmName As String
                highAlarmName = varName & "_High_Alarm"
                MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.DeleteVar (highAlarmName)
                Set newHighAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(highAlarmName, mathDriver, nChannelType, varDataType)
                newHighAlarmsVar.Tagname = varName
                newHighAlarmsVar.DynProperties("AreaName") = cbAlarmArea.Text
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newHighAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newHighAlarmsVar.DynProperties("MathInfo[0].SourceVars[0].Title") = newHighVar
                newHighAlarmsVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newHighAlarmsVar.DynProperties("MathInfo[0].SourceVars[1].Title") = newDisableVar
    
                'define type of formular (6208 = Statistik)
                newHighAlarmsVar.DynProperties("MathInfo[0].Type") = 6208
                'insert formular
                newHighAlarmsVar.DynProperties("MathInfo[0].Formula") = "X02 AND NOT(X01)"
                
                newHighAlarmsVar.EdLimitItem(0).Text = "HIGH LEVEL OFF"
                newHighAlarmsVar.EdLimitItem(0).Cel = True
                newHighAlarmsVar.EdLimitItem(0).DynProperties("GroupName") = m_obDriver.Identification
                newHighAlarmsVar.EdLimitItem(0).DynProperties("Color") = 65280 '00FF00 Verde
                
                newHighAlarmsVar.EdLimitItem(1).Alarm = True
                newHighAlarmsVar.EdLimitItem(1).Text = "HIGH LEVEL ON"
                newHighAlarmsVar.EdLimitItem(1).Cel = True
                newHighAlarmsVar.EdLimitItem(1).DynProperties("GroupName") = m_obDriver.Identification
                newHighAlarmsVar.EdLimitItem(1).DynProperties("Color") = 255 'FF0000 Rosso
                newHighAlarmsVar.EdLimitItem(1).Blinking = True
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newInvalidVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newInvalidVar.DynProperties("MathInfo[0].SourceVars[" & invIdx & "].Title") = newHighVar
                invIdx = invIdx + 1
            End If
            
            If ckbOverflow.value = True Then
                Set newOverflowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(varName & "_Overflow", varDriver, varChannelType, varDataType)
                newOverflowVar.Tagname = varName
                Dim overflowAlarmName As String
                overflowAlarmName = varName & "_Overflow_Alarm"
                MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.DeleteVar (overflowAlarmName)
                Set newOverflowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(overflowAlarmName, mathDriver, nChannelType, varDataType)
                newOverflowVar.Tagname = varName
                newOverflowVar.DynProperties("AreaName") = cbAlarmArea.Text
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newOverflowVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newOverflowVar.DynProperties("MathInfo[0].SourceVars[0].Title") = newOverflowVar
                newOverflowVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newOverflowVar.DynProperties("MathInfo[0].SourceVars[1].Title") = newDisableVar
    
                'define type of formular (6208 = Statistik)
                newOverflowVar.DynProperties("MathInfo[0].Type") = 6208
                'insert formular
                newOverflowVar.DynProperties("MathInfo[0].Formula") = "X02 AND NOT(X01)"
                
                newOverflowVar.EdLimitItem(0).Text = "OVERFLOW LEVEL OFF"
                newOverflowVar.EdLimitItem(0).Cel = True
                newOverflowVar.EdLimitItem(0).DynProperties("GroupName") = m_obDriver.Identification
                newOverflowVar.EdLimitItem(0).DynProperties("Color") = 65280 '00FF00 Verde
                
                newOverflowVar.EdLimitItem(1).Alarm = True
                newOverflowVar.EdLimitItem(1).Text = "OVERFLOW LEVEL ON"
                newOverflowVar.EdLimitItem(1).Cel = True
                newOverflowVar.EdLimitItem(1).DynProperties("GroupName") = m_obDriver.Identification
                newOverflowVar.EdLimitItem(1).DynProperties("Color") = 255 'FF0000 Rosso
                newOverflowVar.EdLimitItem(1).Blinking = True
                
                'add Source Variable (i.e. Boolean from Internal driver - has to exist already)
                newInvalidVar.CreateDynProperty ("MathInfo[0].SourceVars")
                newInvalidVar.DynProperties("MathInfo[0].SourceVars[" & invIdx & "].Title") = newOverflowVar
                invIdx = invIdx + 1
            End If
            
            'define type of formular (6208 = Statistik)
            newInvalidVar.DynProperties("MathInfo[0].Type") = 6208
            If invIdx = 2 Then
                'insert formular
                newInvalidVar.DynProperties("MathInfo[0].Formula") = "(X02 AND NOT(X01))"
            ElseIf invIdx = 3 Then
                'insert formular
                newInvalidVar.DynProperties("MathInfo[0].Formula") = "(X02 AND NOT(X01)) OR (X03 AND NOT(X01 AND X02))"
            ElseIf invIdx = 4 Then
                'insert formular
                newInvalidVar.DynProperties("MathInfo[0].Formula") = "(X02 AND NOT(X01)) OR (X03 AND NOT(X01 AND X02)) OR (X04 AND NOT(X03 AND X02 AND X01))"
            ElseIf invIdx = 5 Then
                'insert formular
                newInvalidVar.DynProperties("MathInfo[0].Formula") = "(X02 AND NOT(X01)) OR (X03 AND NOT(X01 AND X02)) OR (X04 AND NOT(X03 AND X02 AND X01)) OR (X05 AND NOT(X04 AND X03 AND X02 AND X01))"
            End If
            
            newInvalidVar.EdLimitItem(0).Text = "INVALID OFF"
            newInvalidVar.EdLimitItem(0).Cel = True
            newInvalidVar.EdLimitItem(0).DynProperties("GroupName") = m_obDriver.Identification
            newInvalidVar.EdLimitItem(0).DynProperties("Color") = 65280 '00FF00 Verde
            
            newInvalidVar.EdLimitItem(1).Alarm = True
            newInvalidVar.EdLimitItem(1).Text = "INVALID ON"
            newInvalidVar.EdLimitItem(1).Cel = True
            newInvalidVar.EdLimitItem(1).DynProperties("GroupName") = m_obDriver.Identification
            newInvalidVar.EdLimitItem(1).DynProperties("Color") = 255 'FF0000 Rosso
            newInvalidVar.EdLimitItem(1).Blinking = True
            
            Set newDisableVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(disableName, internalDriver, internChannelType, boolVarType)
            newDisableVar.DynProperties("Remanenz") = 1
            newDisableVar.DynProperties("Initial_value") = 1
            
            Set newSimuVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.CreateVar(simuName, internalDriver, internChannelType, boolVarType)
        Else
            If ckbVeryLow.value = True Then
                Set newVeryLowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_VeryLow")
                Set newVeryLowAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_VeryLow_Alarms")
            End If
            If ckbLow.value = True Then
                Set newLowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Low")
                Set newLowAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Low_Alarms")
            End If
            If ckbHigh.value = True Then
                Set newHighVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_High")
                Set newHighAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_High_Alarms")
            End If
            If ckbOverflow.value = True Then
                Set newOverflowVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Overflow")
                Set newOverflowAlarmsVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Overflow_Alarms")
            End If
            Set newNormalVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Normal")
            
            Set newInvalidVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Invalid")
            
            Set newDisableVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Enable")
            
            Set newSimuVar = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(tbVarName.Text & "_Simulation")
        End If
        
        'get all DynProperties of the actual object (DynPicture, Element, ...)
        vProps = m_obElem.DynPropertiesEnum("")
    
        For it = 0 To UBound(vProps)
            strProp = Split(vProps(it), ",")
            If InStr(1, vProps(it), "StatusDisabled") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newDisableVar
            ElseIf InStr(1, vProps(it), "offline") > 0 Then
                m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(m_obDriver.Identification & "_offline")
            ElseIf InStr(1, vProps(it), "Empty") > 0 Then
                If ckbVeryLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newVeryLowVar
                ElseIf ckbLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "VeryLow") > 0 Then
                If ckbVeryLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newVeryLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Low") > 0 Then
                If ckbLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Normal") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newNormalVar
            ElseIf InStr(1, vProps(it), "High") > 0 Then
                If ckbHigh.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newHighVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Overflow") > 0 Then
                If ckbOverflow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newOverflowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Label") > 0 Then
                Dim splitVarName() As String
                splitVarName = Split(varName, "_")
                On Error GoTo Error2
                m_obElem.DynProperties(strProp(0)) = splitVarName(1)
            ElseIf InStr(1, vProps(it), "Invalid") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newInvalidVar
            ElseIf InStr(1, vProps(it), "Tooltip") > 0 Then
                m_obElem.DynProperties(strProp(0)) = varName
            End If
    Error2:
        Next it
        m_obElem.DynProperties("SubstituteSource") = "Var*"
        m_obElem.DynProperties("SubstituteDestination") = varName & "_"
        Me.Hide
        Exit Sub
    Error:
        MsgBox "Error occurs in method pbOk_Click: " + Err.Description + " Source " + Err.Source
    End Sub
    The variables association with my symbol properties starts at the end of the function:
    'get all DynProperties of the actual object (DynPicture, Element, ...)
        vProps = m_obElem.DynPropertiesEnum("")
    
        For it = 0 To UBound(vProps)
            strProp = Split(vProps(it), ",")
            If InStr(1, vProps(it), "StatusDisabled") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newDisableVar
            ElseIf InStr(1, vProps(it), "offline") > 0 Then
                m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item(m_obDriver.Identification & "_offline")
            ElseIf InStr(1, vProps(it), "Empty") > 0 Then
                If ckbVeryLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newVeryLowVar
                ElseIf ckbLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "VeryLow") > 0 Then
                If ckbVeryLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newVeryLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Low") > 0 Then
                If ckbLow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newLowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Normal") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newNormalVar
            ElseIf InStr(1, vProps(it), "High") > 0 Then
                If ckbHigh.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newHighVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Overflow") > 0 Then
                If ckbOverflow.value = True Then
                    m_obElem.DynProperties(strProp(0)) = newOverflowVar
                Else
                    m_obElem.DynProperties(strProp(0)) = MyWorkspace.Application.Projects.Item(cbProjects.Text).Variables.Item("Invisible")
                End If
            ElseIf InStr(1, vProps(it), "Label") > 0 Then
                Dim splitVarName() As String
                splitVarName = Split(varName, "_")
                On Error GoTo Error2
                m_obElem.DynProperties(strProp(0)) = splitVarName(1)
            ElseIf InStr(1, vProps(it), "Invalid") > 0 Then
                m_obElem.DynProperties(strProp(0)) = newInvalidVar
            ElseIf InStr(1, vProps(it), "Tooltip") > 0 Then
                m_obElem.DynProperties(strProp(0)) = varName
            End If
    Error2:
        Next it

    Where cbProject.Text is the field in my wizard window where I choose the project where variables are created.
    Where is the problem?
    Attached Thumbnails Attached Thumbnails VarCreationCBProjects.png  

  2. #2

    Default Re: Variables association error in child project

    Hi,

    Please try it like this:

    m_obElem.DynProperties(strProp(0)) = cbProjects.Text & "#Invisible"

    This way you are linking the variable through the projectname#variablename syntax.

    Regards,
    Mark

  3. #3
    Join Date
    19.05.2010
    Posts
    17

    Default Re: Variables association error in child project

    Ok, it's working now.
    Thank you.

Similar Threads

  1. error on restoring a project backup
    By markclemens in forum zenon Supervisor
    Replies: 3
    Last Post: 31st March 2012, 09:26
  2. Replies: 12
    Last Post: 25th November 2010, 10:54
  3. Error in creating project backup
    By roberto1978 in forum zenon Supervisor
    Replies: 6
    Last Post: 15th November 2010, 10:05
  4. PLC Variables and Internal Variables
    By madphilly in forum Drivers
    Replies: 1
    Last Post: 4th June 2008, 06:59
  5. Replies: 0
    Last Post: 20th March 2008, 10:20

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •