# Re: 如何在Form上动态加上Timer物件（使用VB6)

Posted by j on October 24, 1999 at 06:13:28:

In Reply to: 如何在Form上动态加上Timer物件（使用VB6) posted by Louis Lu on October 20, 1999 at 17:21:34:

: 首先谢谢小吴上次解决在Module上建立Timer的方式！！

: 一般要使用timer须在form上建立有形的timer物件（以拖拉的方式），
: 但我们可否在Form中在执行时加上timer物件？？？？

Dim i As Integer
Dim WithEvents tmrNew As Timer

Private Sub Command1_Click()
'新增控制项
Set tmrNew = Form1.Controls.Add("VB.Timer", "tmrNew")
tmrNew.Interval = 100
End Sub

'新增控制项事件
Private Sub tmrNew_Timer()
i = i + 1
Caption = i
End Sub

Follow Ups: