Guest User

DEX2 Fail Example

a guest
May 16th, 2017
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2.  
  3. Public WithEvents rtConn As EikonDesktopDataAPI
  4.  
  5. Private m_dex2mgr As Dex2Lib.Dex2Mgr
  6. Private m_dex2mgrADC As Dex2Lib.IDex2Mgr
  7. Private m_cookie As Long
  8. Private WithEvents m_rdata As Dex2Lib.RData
  9.  
  10.  
  11. Private Sub Command0_Click()
  12.     Call ConnectToEikon
  13.     Call CloseDex2
  14. End Sub
  15.  
  16. Sub ConnectToEikon()
  17.     If Not rtConn Is Nothing Then Set rtConn = Nothing
  18.     Set rtConn = New EikonDesktopDataAPI
  19.    
  20.     If rtConn Is Nothing Then
  21.         MsgBox "Failed to create Eikon connection"
  22.         Exit Sub
  23.     End If
  24.    
  25.     rtConn.Initialize
  26.    
  27.     If rtConn.Status = 1 Then Call rtConn_OnStatusChanged(1)
  28.     Exit Sub
  29. End Sub
  30.  
  31. Private Sub m_rdata_OnUpdate(ByVal DataStatus As Dex2Lib.DEX2_DataStatus, ByVal Error As Variant)
  32.     Dim strDataStatus As String
  33.     Dim result As Variant
  34.     Dim c, r As Integer
  35.    
  36.     On Error GoTo errHandler
  37.    
  38.     If DataStatus = DE_DS_FULL Or DataStatus = DE_DS_PARTIAL Then
  39.         result = m_rdata.data
  40.        
  41.         ' c for columns, r for rows.'
  42.        For r = 0 To UBound(result, 1)
  43.             For c = 0 To UBound(result, 2)
  44.                 If VarType(result(r, c)) = vbError Then
  45.                     Debug.Print "#N/A"
  46.                 Else
  47.                     Debug.Print result(r, c)
  48.                 End If
  49.             Next c
  50.         Next r
  51.     End If
  52.  
  53.     ' Call Acknowledge to tell Dex2 that we have got the data'
  54.    m_rdata.Acknowledge
  55.     Exit Sub
  56.    
  57. errHandler:
  58.     Debug.Print Err.Number & ":" & Err.Description
  59. End Sub
  60.  
  61. Private Sub rtConn_OnStatusChanged(ByVal EStatus As EikonDesktopDataAPILib.EEikonStatus)
  62.     If EStatus = Connected Or EStatus = LocalMode Then
  63.         Set m_dex2mgr = rtConn.CreateDex2Mgr
  64.         Set m_dex2mgrADC = m_dex2mgr
  65.         m_cookie = m_dex2mgrADC.Initialize(DE_MC_ADC_POWERLINK)
  66.         Set m_rdata = m_dex2mgrADC.CreateRData(m_cookie)
  67.         m_rdata.InstrumentIDList = "TRI.N"
  68.         m_rdata.FieldList = "TR.RIC"
  69.         m_rdata.Subscribe (False)
  70.     End If
  71. End Sub
  72.  
  73. Sub CloseDex2()
  74.     If Not m_cookie = 0 Then
  75.         m_dex2mgrADC.Finalize (m_cookie)
  76.         m_cookie = 0
  77.         Set m_dex2mgrADC = Nothing
  78.         Set m_rdata = Nothing
  79.     End If
  80. End Sub
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×