等级: 超级版主
- 注册:
- 2021-5-24
- 曾用名:
|
我帮你写了一个示范代码:
要点:
1、在list的changge事件(或者Click事件),获取当前选中的项目的合约,分解出市场代码和合约代码;
2、使用Application对象的ActiveFrame方法打开框架;
3、获取指定名称的窗格(Grid),调用Grid对象的ChangeStock和ChangeCyc更换合约和周期。
Sub frmList_ListBox1_Change()
on error resume next
iRow=frmList_ListBox1.ListIndex
if iRow<0 then exit sub
sCode1=frmList_ListBox1.List(iRow,0)
sCode=Right(sCode1,len(sCode1)-2)
sMarket=left(sCode1,2)
'Application.MsgOut iRow & "," & sCode & "," &sMarket
ActiveCode sCode,sMarket
End Sub
Sub ActiveCode(sCode,sMarket)
Application.ActivateFrame "Technic"
set grid=Technic.GetGridByName("Main")
iCyc=grid.CycType
'grid.ReInitDataFormula'重新刷新窗格内公式
call grid.ChangeStock(sCode,sMarket)
call grid.ChangeCyc(iCyc, 1) '刷新
End Sub |
|