Results 1 to 15 of 15

Thread: [RESOLVED] DDE with Amibroker

Threaded View

  1. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: DDE with Amibroker

    Well, one more shot & I think you should be able to adapt the following example to your needs.
    I assume you want to use the same server form for multiple ticker symbols by changing the server form's LinkTopic. Unsure if it is possible, but you can create a form for each ticker, dynamically.

    I. DDE Server - New project
    1. On Form1, add 1 command button
    2. Add new form & add 2 textboxes there. Name one of them LAST and the other BID
    3. On that new form, change LinkMode property to: 1
    4. Paste this code in Form1
    Code:
    Option Explicit
    
    Private Sub Command1_Click() ' example loading 2 forms for 2 tickers
        Dim f As Form2
        Set f = New Form2 
        With f
            f.LinkTopic = "DELL" ' client link topic
            f.Last.Text = "DELL 'Last' Field" ' sample data
            f.Bid.Text = "DELL 'Bid' Field" ' sample data
        End With
        Set f = New Form2
        With f
            f.LinkTopic = "MSFT" ' client link topic
            f.Last.Text = "MSFT 'Last' Field" ' sample data
            f.Bid.Text = "MSFT 'Bid' Field" ' sample data
        End With
        Command1.Enabled = False
    End Sub
    
    Private Sub Form_Load()
        Command1.Caption = "Load Tickers"
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Dim f As Variant
        For Each f In Forms
            If Not f Is Me Then Unload f
        Next
    End Sub
    II. DDE Client
    1. New project, add 2 textboxes and 2 command button. Leave all default named
    2. Add this code to the form
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Command1.Caption = "MSFT"
        Command2.Caption = "DELL"
    End Sub
    
    Private Sub Command1_Click()
        With Text1
            .LinkItem = "LAST" ' name of server's text box
            .LinkTopic = "Project1|MSFT" ' rename Project1 to Server's eventual EXE name
            .LinkMode = vbLinkAutomatic
        End With
        With Text2
            .LinkItem = "BID" ' name of server's text box
            .LinkTopic = Text1.LinkTopic
            .LinkMode = vbLinkAutomatic
        End With
    End Sub
    
    Private Sub Command2_Click()
        Text1.LinkTopic = "Project1|DELL" ' rename Project1 to Server's eventual EXE name
        Text2.LinkTopic = Text1.LinkTopic
        Text1.LinkMode = vbLinkAutomatic ' changing linktopic breaks connection, re-connect
        Text2.LinkMode = vbLinkAutomatic
    End Sub
    III. Example
    1. Run the server & click the command button
    2. Run the client. Click the MSFT then DELL
    Last edited by LaVolpe; Aug 17th, 2010 at 11:54 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width