Variables.CreateVar



CreateVar(strName As String,lpDriver As LPDISPATCH,kTypes As tpKanaltypes,lpVarType As LPDISPATCH) As Variable

Parameters

strName As String
Name of the new Variable object as string
lpDriver As LPDISPATCH
Needs a driver as an object. Example: zDrivers.Item(0)
kTypes As tpKanaltypes
Channel type as a constant.
List of constants: tpKanaltypes
lpVarType As LPDISPATCH
Needs the datatype of the variable as an object. Example: zVarTypes.Item("INT")
ED
avaliable
RT
not used

Remarks

With this method you are able to create new variables within a project.

Sample:


Sub CreateVariable()

Dim zVariables As Variables 'Object from type Variables
Dim zVariable As Variable 'Child object from type Variables
Dim zDrivers As Drivers 'Object from type Drivers
Dim zVarTypes As VarTypes 'Object from type VarTypes

'Fill the objects
Set zVariables = MyWorkspace.ActiveDocument.Variables
Set zDrivers = MyWorkspace.ActiveDocument.Drivers
Set zVarTypes = MyWorkspace.ActiveDocument.VarTypes

'Create a "intern driver" variable called "TestVariable" with object type "internal variable" and datatype "INT"
Set zVariable = zVariables.CreateVar("TestVariable", zDrivers.Item(0), 33, zVarTypes.Item("INT"))

End Sub


tpKanaltypes constants:

Channel type Constant
tpAdChan 1
tpConfigDef 6
tpControlStatus 0
tpCsDaialogLast 95
tpCsDbFirst 96
tpCsDbLast 127
tpCsDbDialog 80
tpCsFirst 64
tpCsLast 79
tpDaChan 2
tpDataBlock 25
tpDataTakerChan 18
tpDatenbaustein 15
tpDigital 3
tpDriverVariable 35
tpExBaustein 34
tpEzObjekt 32
tpFilter 4
tpHWStatus 24
tpInitFile 14
tpProgram 19
tpSonderMerker 9
tpSonderMerker1 36
tpSPSAusgang 11
tpSPSDatenRegister 20
tpSPSEingang 10
tpSPSFileRegister 21
tpSPSMerker 8
tpSPSTimer 22
tpSPSZaehler 23
tpStrings 5
tpSystemVariable 33
tpTerminal 16
tpTimerEvent 12
tpTriggerEvent 13
tpVirtuell 7
tpVirtuellOnlBerechnen 17

See Also

Variables, Variable