Results 1 to 8 of 8

Command button auto run

Threaded View

  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Command button auto run

    Does any expert can help me to modify this file which is created by my friend before , I want to modify the "Trade" Button to auto run , if range F3:I3 is blank - no action, if range F3:I3 has figure - "Trade" Button will auto run itself. Here is the VBA

    text1.pngtext2.png


    Public channelno As Long
    Public cmdstr As String
    Public cmdID As Integer
    Public DELIMITER As String
    Public cur_index As Integer
    
    
    Private Sub CommandButton1_Click()
    Dim tmpstr As String
    
    channelno = DDEInitiate("xx.xx", "Trade")
    cur_index = 3
    cmdID = 0
    DELIMITER = "~:~"
    cmdstr = Trim(Str(cmdID)) & DELIMITER & "LOGIN" & DELIMITER & "ID=12345678" & DELIMITER & "CH=ABCD"
    tmpstr = "M" & Format(cur_index)
    Range(tmpstr) = cmdstr
    cur_index = cur_index + 1
    cmdID = cmdID + 1
    DDEPoke channelno, "command", Range(tmpstr)
    End Sub
    
    
    Private Sub CommandButton2_Click()
    Dim myvar As Variant
    Dim restr As String
    
    cmdstr = Trim(Str(cmdID)) & DELIMITER & "TRADELFUTURES" & DELIMITER & "Accode=12345678" & DELIMITER & "Code=" & Range("F3").Text & DELIMITER & "Side=" & Range("I3").Text & DELIMITER & "Qty=" & Range("H3").Text & DELIMITER & "Price=" & Range("g3").Text
    tmpstr = "M" & Format(cur_index)
    Range(tmpstr) = cmdstr
    cur_index = cur_index + 1
    cmdID = cmdID + 1
    DDEPoke channelno, "command", Range(tmpstr)
    End Sub
    
    
    Private Sub CommandButton4_Click()
    DDETerminate (channelno)
    End Sub
    Last edited by Paul; 05-16-2012 at 11:30 AM. Reason: Added CODE tags for new user. Please do so yourself in the future.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1