框架vba編程指定窗口顯示合約? [金字塔]
- 咨詢內(nèi)容:
對于包含多個周期窗口的框架, 點擊表格中期貨主力合約, 希望在日線以下級別窗口中仍然顯示該主力合約的K線圖, 但是在周線和月線窗口則自動顯示對應(yīng)的期貨連續(xù)合約的K線圖, 下面的代碼為什么無法實現(xiàn)切換?
框架名: MyChart, 周線窗口名: WinWeek, 在三個事件中都寫了代碼, 測試在表格中點擊合約 JM09, 結(jié)果 TableChangeStock, TableClickStock 兩個事件被觸發(fā)了, 但是周線窗口并沒有被切換成 JMLX 合約,周線窗口不論是設(shè)成與表格是同一分組, 還是設(shè)成沒有分組, 結(jié)果都一樣
Sub MyChart_TableChangeStock(Grid, Code, Market, Result) Application.MsgOut "TableChangeStock: Grid.Name=" & Grid.Name &", Code=" & Code & ", Market=" & Market if Code="JM09" THEN Application.MsgOut "TableChangeStock JM09" call MyChart.GetGridByName("WinWeek").ChangeStock("JMLX","DQ") MyChart.GetGridByName("WinWeek").reInitData MyChart.Refresh 'MyChart.InitAllGrid END IF
End Sub
Sub MyChart_TableClickStock(Grid, Code, Market, Result) Application.MsgOut "TableClickStock: Grid.Name=" & Grid.Name &", Code=" & Code & ", Market=" & Market if Code="JM09" THEN Application.MsgOut "TableClickStock JM09" call MyChart.GetGridByName("WinWeek").ChangeStock("JMLX","DQ") MyChart.GetGridByName("WinWeek").reInitData MyChart.Refresh 'MyChart.InitAllGrid END IFEnd Sub
Sub MyChart_ChangeStock(Grid, Code, Market, Result) Application.MsgOut "ChangeStock: Grid.Name=" & Grid.Name &", Code=" & Code & ", Market=" & Market if Code="JM09" THEN Application.MsgOut "ChangeStock JM09" call MyChart.GetGridByName("WinWeek").ChangeStock("JMLX","DQ") MyChart.GetGridByName("WinWeek").reInitData MyChart.Refresh 'MyChart.InitAllGrid END IFEnd Sub - 金字塔客服:
把你做的框架導(dǎo)出來,我們看看
- 用戶回復(fù):
直接在這里上傳吧
另外存在問題, 每次打開框架時都會跳出4次錯誤提示窗口: "操作文檔數(shù)據(jù)時遇到了一個錯誤。"不知道是我的表格指定的表頭問題, 還是表頭對應(yīng)的指標(biāo)問題?
下載信息 [文件大小: 下載次數(shù): ]點擊瀏覽該文件:issue.rar
- 網(wǎng)友回復(fù):
你的合約代碼寫錯了
焦煤連續(xù)的合約金字塔代碼是JM00
call MyChart.GetGridByName("WinWeek").ChangeStock("JM00","DQ")
其他的代碼也都有類似的問題.
還有你的資料給的不全,有幾個TAB表沒給,我這里沒法完整運行你的東西,你試試改完后再看看
- 網(wǎng)友回復(fù):
謝謝提醒, 經(jīng)過重新編寫測試, 自動切換功能已經(jīng)實現(xiàn), 發(fā)布在這里供其他有需要的人參考一下:以下內(nèi)容為程序代碼:
1 '調(diào)用子過程, 可存放于全局 Global模塊中
2 Sub FrameSwitchStock(Frame, Grid, Code, Market, IndexWinName)
3 dim indexCode, indexMarket
4 indexCode = Code
5 indexMarket = Market
6
7 '期貨品種的周線顯示對應(yīng)的連續(xù)合約
8 if Market="DQ" OR Market="ZJ" OR Market="SQ" or Market="SY" or Market="ZQ" then '有什么方法可以方便地判斷指定市場的種類是期貨市場 ?
9 indexCode = Left(Code,Len(Code)-2) & "00"
10 indexMarket = Market
11 end if
12
13 Set IndexGrid = Frame.GetGridByName(IndexWinName)
14 if IndexGrid is Nothing then
15 Application.MsgOut "目標(biāo)窗口不存在: " & IndexWinName
16 else
17 if IndexGrid.StockLabel<> indexCode THEN
18 call IndexGrid.ChangeStock(indexCode, indexMarket)
19 IndexGrid.reInitData
20 Frame.Refresh
21 Frame.InitAllGrid
22 END IF
23 end if
24 end Sub
25
26 '從列表切換合約時觸發(fā)
27 Sub MyChart_TableChangeStock(Grid, Code, Market, Result)
28 'Application.MsgOut "TableChangeStock: Grid.Name=" & Grid.Name &", Code=" & Code & ", Market=" & Market
29 call FrameSwitchStock(MyChart, Grid, Code, Market, "WeekWin")
30 call FrameSwitchStock(MyChart, Grid, Code, Market, "MonthWin")
31 End Sub
32
33 '子窗口直接輸入代碼切換合約時觸發(fā)
34 Sub MyChart_ChangeStock(Grid, Code, Market, Result)
35 'Application.MsgOut "ChangeStock: Grid.Name=" & Grid.Name &", Code=" & Code & ", Market=" & Market
36 if Grid.Name <> "WeekWin" then
37 call FrameSwitchStock(MyChart, Grid, Code, Market, "WeekWin")
38 end if
39 if Grid.Name <> "MonthWin" then
40 call FrameSwitchStock(MyChart, Grid, Code, Market, "MonthWin")
41 end if
42 End Sub
43
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫!(不貴!點擊查看價格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容