我现在要用到一个Timer
这个timer要自己定义出来
就向这样 dim mt = new Timer
但是死活就是不行
有什么办法可以做到?
这个timer要自己定义出来
就向这样 dim mt = new Timer
但是死活就是不行
有什么办法可以做到?
解决方案 »
- 【调查帖】除了编程,你还有什么后手可以成为谋生手段?
- 为什么Form_Load 事件里设置某个控件获得焦点会报错啊
- 请教:如何用ADO+SQL语句创建一个ACCESS数据库?
- 寻找像QQ中的上下可移动显示(分页显示)的控件
- 几个简单但让我奇怪的问题
- 怎么限制TEXTBOX的内容?只能输入0—100的数字怎么做?帮忙呀
- 如何在自定义控件中只显示一幅透明GIF图,而不要控件窗体底色?
- 给高分!(200分)请问有东莞的程序员吗!我有问题要问你们!
- 程序源代码
- VB中create table麻烦,?
- 在使用winsock时,采用不同的开发语言,服务器-客户端也可以连接吗???
- (VB) 超级列表框控件在哪儿目录下呢?
Option Base 0
Option Explicit
DefLng A-N, P-Z
DefBool OPrivate mEnabled As Boolean
Private mInterval As Long
Private mStart As Long
Private mName As String
Public Event OnTimer()Private Declare Function GetTickCount Lib "kernel32" () As LongPublic Property Get Enabled() As Boolean
Enabled = mEnabled
End PropertyPublic Property Let Enabled(ByVal vEnabled As Boolean)
mEnabled = vEnabled
mStart = 0
Call Running
End PropertyPublic Property Let Interval(vInterval As Long)
If vInterval > 0 Then
mStart = 0
mInterval = vInterval
Call Running
Else
mInterval = 0
mStart = 0
mEnabled = False
End If
End PropertyPublic Property Get Interval() As Long
Interval = mInterval
End PropertyPublic Property Let Name(vName As String)
If vName <> "" Then
mName = vName
End If
End PropertyPublic Property Get Name() As String
Name = mName
End Property
Private Sub Running()
Dim Elapsed As LongDo While mEnabled
If mStart = 0 Then
mStart = GetTickCount
End If
Elapsed = GetTickCount
If (Elapsed - mStart) >= mInterval Then
mStart = GetTickCount
RaiseEvent OnTimer
End If
DoEvents
LoopEnd SubPrivate Sub Class_Initialize()
mEnabled = False
mInterval = 1000
mName = "ArielTimer"
End SubPrivate Sub Class_Terminate()
mEnabled = False
End Sub
Set theTimer = Me.Controls.Add("VB.Timer", "tmrTest")
theTimer.Interval = 1000
theTimer = True
End SubPrivate Sub theTimer_Timer()
Debug.Print Timer
End Sub
有完整源代码