What's wrong with my code?
Cube: Exchange Rate
Dimension : Year
Dimension : Month
Dimension : Currency
Dimension : Rate_m
Code: Select all
Private Sub Form_Load()
Dim sServerName As String
Dim sUsername As String
Dim sPassword As String
Dim hUserHandle As Long
Dim pPoolHandle As Long
Dim vPassword, vServerName, vUserName As Long
Dim vStringLength As Long
Dim RetVal As String * 75
TM1APIInitialize
hUser = TM1SystemOpen()
TM1SystemAdminHostSet hUser, "rjordon"
pPoolHandle = TM1ValPoolCreate(hUser)
'
' We have to take the strings containing the login information (such as the
' user name and password) and turn them into TM1 value capsules.First
' establish the maximum length of the string as 10 characters.
'
vStringLength = TM1ValIndex(pPoolHandle, 10)
'
' Next, use this string length to build value capsules for the
' user name, password, and TM1Server name. We can reuse the pool Handle
' for these functions.
'
vUserName = TM1ValString(pPoolHandle, "admin", vStringLength)
vPassword = TM1ValString(pPoolHandle, "", vStringLength)
vServerName = TM1ValString(pPoolHandle, "gpdev", vStringLength)
vServerHandle = TM1SystemServerConnect(pPoolHandle, vServerName, vUserName, vPassword)
If (TM1ValType(hUser, vServerHandle) = TM1ValTypeObject()) Then
' MsgBox "You Logged in Successfully"
End If
If (TM1ValType(hUser, vServerHandle) = TM1ValTypeError()) Then
MsgBox "The server handle contains an error code."
End If
Dim year As String
Dim month As String
Dim currency1 As String
Dim rate As String
year = "2009"
month = "April"
currency1 = "EUR"
rate = "rate"
Dim hDimYear As Long
Dim vYear As Long
Dim hDimMonth As Long
Dim vMonth As Long
Dim hDimCurrency As Long
Dim vCurrency As Long
Dim hDimRate As Long
Dim vRate As Long
ReDim elementArray(6) As Long
hDimYear = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Year", 100))
vYear = TM1ObjectListHandleByNameGet(pPoolHandle, hDimYear, TM1DimensionElements(), TM1ValString(pPoolHandle, year, 100))
hDimMonth = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Month", 100))
vMonth = TM1ObjectListHandleByNameGet(pPoolHandle, hDimMonth, TM1DimensionElements(), TM1ValString(pPoolHandle, month, 100))
hDimCurrency = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Currency", 100))
vCurrency = TM1ObjectListHandleByNameGet(pPoolHandle, hDimCurrency, TM1DimensionElements(), TM1ValString(pPoolHandle, currency1, 100))
hDimRate = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerDimensions(), TM1ValString(pPoolHandle, "Rate_m", 100))
vRate = TM1ObjectListHandleByNameGet(pPoolHandle, hDimRate, TM1DimensionElements(), TM1ValString(pPoolHandle, rate, 100))
elementArray(1) = vYear
elementArray(2) = vMonth
elementArray(3) = vCurrency
elementArray(4) = vRate
'create cube handle.
hCubeObject = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerCubes(), TM1ValString(pPoolHandle, "ExchangeRate", 100))
Dim vArrayOfCells As Long
vArrayOfCells = TM1ValArray(pPoolHandle, elementArray, 4)
'set the array values
Call TM1ValArraySet(vArrayOfCells, elementArray(1), 1)
Call TM1ValArraySet(vArrayOfCells, elementArray(2), 2)
Call TM1ValArraySet(vArrayOfCells, elementArray(3), 3)
Call TM1ValArraySet(vArrayOfCells, elementArray(4), 4)
Dim value As Long
value = TM1CubeCellValueGet(pPoolHandle, hCubeObject, elementArrayCapsule)
MsgBox TM1ValType(hUser, value)
'
' To log out and disconnect from the API, you must
' call TM1SystemServerDisconnect, TM1SystemClose, then TM1APIFinalize.
'
' In addition, best practice dictates that all TM1 Value Pools used
' in your program be destroyed by calling TM1ValPoolDestroy().
'
vResult = TM1SystemServerDisconnect(pPoolHandle, vServerName)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Add Code to delete all TM1 Value Pools here.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TM1ValPoolDestroy (pPoolHandle)
TM1SystemClose hUser
TM1APIFinalize
End Sub