启动VB,新建一个ActiveX DLL工程,将工程命名为NewTimer,将类模块名Class1改名为LongTimer。在工程中添加一个窗体Form1,在窗体上加入一个Timer计时器控件Timer1。打开LongTimer类模块,尤肴缦鲁绦虼耄?br> Option Explicit
Public Event Tick() '声明事件
Private nz As Integer
Private cs As Integer
Private m_Form As Form1
Private WithEvents m_Timer As Timer '声明对象类变量
'返回Enable属性值
Public Property Get Enabled() As Boolean
Enabled = m_Timer.Enabled
End Property
'设置Enable属性值
Public Property Let Enabled(ByVal vNewValue As Boolean)
m_Timer.Enabled = vNewValue
End Property
'返回Interval属性值
Public Property Get Interval() As Long
Interval = m_Timer.Interval
End Property
'设置Interval属性值
Public Property Let Interval(ByVal vNewValue As Long)
cs = 0
nz = vNewValue \ 65536 + 1
m_Timer.Interval = vNewValue \ nz
End Property
'类初始化事件
Private Sub CLASS_Initialize()
Set m_Form = New Form1
Load m_Form
Set m_Timer = m_Form.Timer1
End Sub
'类终止事件
Private Sub CLASS_Terminate()
Unload m_Form
Set m_Timer = Nothing
End Sub
'产生Tick事件
Private Sub m_Timer_Timer()
cs = cs + 1
If cs >= nz Then
RaiseEvent Tick
cs = 0
End If
End Sub
窗体Form1只用来作计时器Timer1的载体,不用于显示。
2.测试NewTimer.DLL
上一页 [1] [2] [3] 下一页
VB中创建超长时间计时器对象 第2页下载如图片无法显示或论文不完整,请联系qq752018766