框架vba编程指定窗口显示合约? [金字塔]
- 咨询内容:
对于包含多个周期窗口的框架, 点击表格中期货主力合约, 希望在日线以下级别窗口中仍然显示该主力合约的K线图, 但是在周线和月线窗口则自动显示对应的期货连续合约的K线图, 下面的代码为什么无法实现切换?
框架名: MyChart, 周线窗口名: WinWeek, 在三个事件中都写了代码, 测试在表格中点击合约 JM09, 结果 TableChangeStock, TableClickStock 两个事件被触发了, 但是周线窗口并没有被切换成 JMLX 合约,周线窗口不论是设成与表格是同一分组, 还是设成没有分组, 结果都一样
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 - 金字塔客服:
把你做的框架导出来,我们看看
- 用户回复:
直接在这里上传吧
另外存在问题, 每次打开框架时都会跳出4次错误提示窗口: "操作文档数据时遇到了一个错误。"不知道是我的表格指定的表头问题, 还是表头对应的指标问题?
下载信息 [文件大小: 下载次数: ]点击浏览该文件:issue.rar
- 网友回复:
你的合约代码写错了
焦煤连续的合约金字塔代码是JM00
call MyChart.GetGridByName("WinWeek").ChangeStock("JM00","DQ")
其他的代码也都有类似的问题.
还有你的资料给的不全,有几个TAB表没给,我这里没法完整运行你的东西,你试试改完后再看看
- 网友回复:
谢谢提醒, 经过重新编写测试, 自动切换功能已经实现, 发布在这里供其他有需要的人参考一下:以下内容为程序代码:
1 '调用子过程, 可存放于全局 Global模块中
2 Sub FrameSwitchStock(Frame, Grid, Code, Market, IndexWinName)
3 dim indexCode, indexMarket
4 indexCode = Code
5 indexMarket = Market
6
7 '期货品种的周线显示对应的连续合约
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 "目标窗口不存在: " & 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 '从列表切换合约时触发
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 '子窗口直接输入代码切换合约时触发
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
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容