-- 作者:dzfp2010
-- 发布时间:2010/3/28 16:52:11
--
代码如下,请版主帮忙完善,并对其中一些问题,进行一些优化和提示啊:
Sub UserForm2_Initialize()
\'能不能在初始化过程中直接写这部分代码,以后再用到这些代码的时候,可以省略呢?。。。 Set Grid=UserFrame6.GetGridByName("Main") Set HistoryData=Grid.GetHistoryData()
End Sub
\'窗体载入,设置窗体属性 Sub UserForm2_Load() With userForm2 \'.Caption="=模拟K线=" \'.Width=282 \'.Height=162 .Resizing=0 .MinButton=1 End With \'指定一个自定义的图标 userForm2.SetTitileIcon("MyFile\\Icon\\yinwu.ICO") userForm2.SetDefaultTabOrder() End Sub
\'插入K线 Sub UserForm2_CommandButton2_Click() \'验证TextBox中的数据 IF UserForm2_TextBox1.Text="" Or Not IsNumeric(UserForm2_TextBox1.Text) Then MsgBox "请输入正确的 开盘价 数值。。。" UserForm2_TextBox1.SetFocus Exit Sub End If
IF UserForm2_TextBox2.Text="" Or Not IsNumeric(UserForm2_TextBox2.Text) Then MsgBox "请输入正确的 最高价 数值。。。" UserForm2_TextBox2.SetFocus Exit Sub End If
IF UserForm2_TextBox3.Text="" Or Not IsNumeric(UserForm2_TextBox3.Text) Then MsgBox "请输入正确的 最低价 数值。。。" UserForm2_TextBox3.SetFocus Exit Sub End If IF UserForm2_TextBox4.Text="" Or Not IsNumeric(UserForm2_TextBox4.Text) Then MsgBox "请输入正确的 收盘价 数值。。。" UserForm2_TextBox4.SetFocus Exit Sub End If
\'MsgBox "你点击了插入K线按钮" Set Grid=UserFrame6.GetGridByName("Main") Set HistoryData=Grid.GetHistoryData() HistoryData.InsertAt(HistoryData.Count) \'开盘价 HistoryData.Open(HistoryData.Count-1)=Cint(UserForm2_TextBox1.Text) \'最高价 HistoryData.High(HistoryData.Count-1)=Cint(UserForm2_TextBox2.Text) \'收盘价 HistoryData.Low(HistoryData.Count-1)=Cint(UserForm2_TextBox3.Text) \'最低价 HistoryData.Close(HistoryData.Count-1)=Cint(UserForm2_TextBox4.Text) \'重新计算框架内的所有公式数据、刷新框架 \'UserFrame6.ReCalcAllGrid() \'UserFrame6.Refresh() End Sub
\'删除K线 Sub UserForm2_CommandButton3_Click() Set Grid=UserFrame6.GetGridByName("Main") Set HistoryData=Grid.GetHistoryData() HistoryData.RemoveAt(HistoryData.Count) \'重新计算框架内的所有公式数据、刷新框架 \'UserFrame6.ReCalcAllGrid() \'UserFrame6.Refresh() End Sub
|