Element.CountVariable



CountVariable() As Long
ED
read only
RT
read only

Remarks

Returns the number of variables linked to the dynamic element.

Hint: With the method "ItemVariable" the single variables of the dynamic element can be found out.

Sample

The following VBA example reads all variables of a Trend element and displays them in the Debug window of VBA. Then the user is asked if VBA should be opened, to let him read the messages.

'*** Get variables of trend TREND_1. Public Sub LeftClickUp_Element_Variables(obElem As Element)
	Dim obElement As Element
	Dim obPicture As DynPicture
	Dim obVariable As Variable
	Dim obFunction As RtFunction
	Dim nIndex As Long

	'*** Get picture-Object
	Set obPicture = obElem.Parent.Parent
	If (obPicture Is Nothing) Then
		MsgBox "Error: Picture-object is invalid..."
		Exit Sub
	End If

	'*** Get element TREND_1
	Set obElement = obPicture.Elements.Item("TREND_1")
	If (obElement Is Nothing) Then
		MsgBox "Error: element BITMAP_BTN_1 doesn't exists..."
		Exit Sub
	End If

	'*** Get variables of trend
	Debug.Print "TREND_1: " + CStr(obElement.CountVariable) + " variabls 

are linked with TREND_1"
	For nIndex = 0 To obElement.CountVariable - 1
		Set obVariable = obElement.ItemVariable(nIndex)
		If (Not obVariable Is Nothing) Then
			Debug.Print "TREND_1: Current variable" + obVariable.Name
		End If
	Next nIndex
		
	'*** set button in normal state (unpressed)
	obElem.LeftClickUp

	'*** Open VBA-IDE???
	If (MsgBox("Open the VBA-IDE?", vbYesNo) = vbYes) Then
		'*** Get function for opening the VBA-IDE
		Set obFunction = thisProject.RtFunctions.Item("Open_VBA_IDE")
		If (Not obFunction Is Nothing) Then
			obFunction.Start
		Else
			MsgBox "Error: Function ""OPEN_VBA_IDE"" isn't defined..."
		End If
	End If
End Sub


See Also

Element