My codes'purpose is get an element list from the dimension given a name,the "eCount" variable is the number of elements from dimension given a name.
when give it an empty dimension,the "eCount" 's value is 91,why not 0?
Code: Select all
Public Sub listElements(sServerName, sDimensionName)
Dim hUser As Long
Dim hPool As Long
Dim hServerHandle As Long
Dim hDim As Long
Dim eHCount As Long
Dim sErr As String * 100
Dim eCount As Integer
Dim i As Integer
hUser = TM1_API2HAN()
If hUser = 0 Then
MsgBox "No Connect to API!"
End If
hServerHandle = TM1SystemServerHandle(hUser, sServerName)
If hServerHandle = 0 Then
MsgBox "No Connect to Server"
End If
hPool = TM1ValPoolCreate(hUser)
hDim = TM1ObjectListHandleByNameGet(hPool, hServerHandle, TM1ServerDimensions(), TM1ValString(hPool, sDimensionName, 0))
If TM1ValObjectType(hUser, hDim) = TM1ValTypeError() Then
TM1ValStringGet_VB hUser, hDim, sErr, 100
MsgBox sErr
TM1ValPoolDestroy (hPool)
Exit Sub
End If
eHCount = TM1ObjectListCountGet(hPool, hDim, TM1DimensionElements())
eCount = TM1ValIndexGet(hUser, eHCount)
MsgBox eCount
TM1ValPoolDestroy (hPool)
'For i = 1 To eCount
'TM1ObjectListHandleByIndexGet(hpool,hdim,tm1dimensionelements(),i)
' i = i + 1
'Next
End Sub