I need the Microsoft Code For The Construction Of A Timer. I need it to build a new timer so that it can fit in with my other components!
Printable View
I need the Microsoft Code For The Construction Of A Timer. I need it to build a new timer so that it can fit in with my other components!
All I ask is for someone to post the original timer component code. Other people ask the hardest questions and you reply to them. This is so simple! Like NIKE says, JUST DO IT!!!
Have you asked Microsoft for the code?
I am pretty sure they would be willing to send it to you royalty free...................Not!
Do what we all do.......write your own.
I wrote a code for this about a month ago. It's not that hard once you look at it. Basically this uses GetTickCount for accuracy up to 1ms.
Put the following in a UserControl (call it TimerEx)
Put the following in a Form with a CommandButton and a TimerEx.Code:'Default Property Values:
Const m_def_Enabled = 0
Const m_def_Interval = 0
'Property Variables:
Dim m_Enabled As Boolean
Dim m_Interval As Integer
'Event Declarations:
Event Timer()
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Property Get Enabled() As Boolean
Enabled = m_Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
m_Enabled = New_Enabled
PropertyChanged "Enabled"
Do While m_Enabled = True
start = GetTickCount
Do While GetTickCount < start + m_Interval
DoEvents
Loop
RaiseEvent Timer
Loop
End Property
Public Property Get Interval() As Integer
Interval = m_Interval
End Property
Public Property Let Interval(ByVal New_Interval As Integer)
m_Interval = New_Interval
PropertyChanged "Interval"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_Enabled = m_def_Enabled
m_Interval = m_def_Interval
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
m_Interval = PropBag.ReadProperty("Interval", m_def_Interval)
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
Call PropBag.WriteProperty("Interval", m_Interval, m_def_Interval)
End Sub
Code:Private Sub Command1_Click()
TimerEx1.Interval = 500
TimerEx1.Enabled = True
End Sub
Private Sub TimerEx1_Timer()
Print "Hello"
End Sub