|
本帖最后由 sleeping_dogs 于 2019-6-7 19:00 编辑
Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Public itimerid As Long, timex As Single
Public Sub ontimer()
timex = timex + 0.1
UserForm1.TextBox = Format(timex, "0.0")
End Sub
Private Sub cmdstart_click()
timex = 0
itimerid = SetTimer(0, 0, 100, AddressOf ontimer)
End Sub
Private Sub cmdstop_click()
Call KillTimer(0, itimerid)
End Sub
书本例子是关于制作数字秒表,按书上的代码输入进去,然后运行不成功,报错UserForm1没有TextBox1这个数据成员。这是第一个问题
第二个问题是,这个例子我不明白显示的窗体对象到底是VBA的userform对象产生的,还是系统api函数SETTimer产生的。新手,刚看完基本语法,很多东西还在摸索,求高手指教。
|
|