Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with the Metadata Model: Tutorial > Understanding the Variable and Element classes
 
Understanding the Variable and Element classes
In UNICOM Intelligence Data Model version 2.7, the Variable class changed to support the Variable2 class. This means that when you use the Document.CreateVariable method to create a Variable object, the object that is created is of type IVariable2 rather than IVariable. The newly created object has all of the properties and methods of the Variable2 class in addition to those of the Variable class and the classes from which the Variable class inherits. However, for a variable, the relevant enumeration constant built into the MDM remained as mtVariable.
Similarly, the Element class changed in UNICOM Intelligence Data Model version 2.7 to support the ElementInstance class. When you use the Document.CreateElement method to create an Element object, the object that is created is of type IElementInstance rather than IElement. The newly created object has all of the properties and methods of the ElementInstance class in addition to those of the Element class and the classes from which the Element class inherits. However, the object should still be considered an Element and not an ElementInstance and the relevant enumeration constant built into the MDM remained as mtElement.
You can demonstrate this by opening an .mdd file in Metadata Model Explorer. When you click on a variable in the tree view on the left side, the right side of the window shows its type name as IVariable2. Similarly when you click on an element in the tree view on the left side, the right side shows its type name as IElementInstance.
Apart from the fact that the Variable and Element objects now have a number of useful new properties, these changes are generally invisible. However, you need to be aware of the change in the basic type of the Variable and Element objects if you use the Visual Basic TypeName property to test for an object's type in your code. The following Visual Basic code snippet shows how to take into account the IVariable2 and IElementInstance types:
Dim MyObject As Object

Select Case TypeName(MyObject)
  Case "IVariable", "IVariable2"
    ...
  Case "IElement"
    ...
  Case "IElementInstance"
    If MyObject.ObjectTypeValue = mtElement Then
      ...
    Else
      ...
    End If
  Case Else
    ...
End Select
Next topic
Traversing the Routing collection
See also
Working with the Metadata Model: Tutorial
Creating and saving a variable