question

Upvotes
Accepted
1 1 1 2

Trying my question again from different code editor. I can get realtime data from the api using vb but not the non-realtime data. Hoping the form doesn't munge the code from this editor.

Option Explicit


Private Sub Form_Load()
    Me.WindowState = vbMaximized
End Sub


Sub Sleep_DoEvents(msg As String, Optional Milliseconds As Long = 3000)
    Dim tc As Long
    
    Form1.Caption = msg
    
    tc = GetTickCount
    
    While GetTickCount < tc + Milliseconds
        Sleep 1
        DoEvents
    Wend
End Sub


Private Sub cmdNonRealtime_Click()
    
    Dim MyEikonDDA As EikonDesktopDataAPI
    Dim MyDex2Mgr As Dex2Mgr
    Dim MyRData As Dex2Lib.RData
    Dim MyDex2Cookie As Long
    Dim MyFieldList As Variant
    Dim MyItemList As Variant
    Dim msg As String
    Dim EikonInitResult As EikonDesktopDataAPILib.EEikonDataAPIInitializeResult
    Dim Value_Returned
    Dim DataStatus As Dex2Lib.DEX2_DataStatus
    Dim MyRequestParamList As Variant
    
    MyFieldList = "TR.CompanyName"
    
    MyItemList = "GS"
    
    MyRequestParamList = ""
    
    Set MyEikonDDA = New EikonDesktopDataAPI
    msg = "Waiting after Set EikonDDA = New EikonDesktopDataAPI"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    EikonInitResult = MyEikonDDA.Initialize
    
    If EikonInitResult = Error_InitializeFail Then
        MsgBox "The result of EikonDDA.Initialize was Error_InitializeFail, end"
        End
    End If
    
    If EikonInitResult = Error_Reinitialize Then
        MsgBox "The result of EikonDDA.Initialize was Error_Reinitialize, end"
        End
    End If
    
    If EikonInitResult = Succeed Then
        MsgBox "The result of EikonDDA.Initialize was Succeed, continue"
    End If
    
    msg = "Waiting after EikonDDA.Initialize"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    If EikonInitResult = Error_InitializeFail Then
        'Handle fail case here
    ElseIf EikonInitResult = Error_Reinitialize Then
        'Handle reinitialize case here
    End If
    
    msg = "Waiting before EikonDDA.CreateDex2Mgr"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    Set MyDex2Mgr = MyEikonDDA.CreateDex2Mgr()
    msg = "Waiting after Set MyDex2Mgr = EikonDDA.CreateDex2Mgr"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    MyDex2Cookie = MyDex2Mgr.Initialize(DE_MC_ADC_POWERLINK)
    
    msg = "Waiting after MyDex2Mgr.Initialize"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    Set MyRData = MyDex2Mgr.CreateRData(MyDex2Cookie)
    msg = "Waiting after MyDex2Mgr.MyDex2Mgr.CreateRData"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    MyRData.FieldList = MyFieldList
    MyRData.InstrumentIDList = MyItemList
    MyRData.DisplayParam = "RH:In CH:Fd"
    MyRData.RequestParam = MyRequestParamList
    
    MyRData.Subscribe
    
    msg = "Waiting after MyRData.Subscribe"
    Sleep_DoEvents msg, Milliseconds:=SLEEP_LENGTH
    
    If MyRData Is Nothing Then
        
    Else
        
        Value_Returned = MyRData.Data(1, 1)
        
        ' ?err.Description
        ' Method 'Data' of object 'IRData' failed
    
        MsgBox Value_Returned
    End If
    
End Sub


eikonapieikon-com-apivb
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@kent_finkle
Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.
Thanks,
-AHS

@kent_finkle

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If yes please click the 'Accept' next to the appropriate reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such. Thanks, AHS

1 Answer

· Write an Answer
Upvotes
Accepted
39.4k 77 11 27

You're not initializing Dex2 Manager correctly. You're missing a cast from Dex2Mgr class to IDex2Mgr2 interface, which is required. See VB code sample in this tutorial, Step2 - Create DEX2 object and initialize DEX2.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.