[Digital-X-Treme]
Jul 14th, 2001, 09:55 AM
I have the following code:
'CTimer.cls
Option Explicit
Event Timer()
Private WithEvents mTimer As Timer
Private intCount As Integer
Public Property Let Interval(ByVal intInterval As Integer)
mTimer.Interval = intInterval
End Property
Public Property Get Interval() As Integer
Interval = intInterval
End Property
Private Sub Class_Initialize()
mTimer.Enabled = True
Debug.Print "Initialized..."
End Sub
Private Sub mTimer_Timer()
intCount = intCount + 1
RaiseEvent Timer
End Sub
Public Sub Count()
Debug.Print intCount
End Sub
'Form1
Option Explicit
Private WithEvents mTimerObj As CTimer
Private Sub Form_Load()
Set mTimerObj = New CTimer
End Sub
Private Sub mTimerObj_Timer()
Debug.Print "Timer Event!"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mTimerObj = Nothing
End Sub
Now, what im trying to do is basically encapsulate the timer control inside a class, with a few extra properties.
When i run the above code, i get an error when the Class_Initialize() sub runs, saying "Object variable or With Block variable Not Set". Any ideas?
I want to do this without building a separate OCX. I have never really looked into ActivX before. Can anyone point me in the right direction?
Thanks in advance :)
Laterz
'CTimer.cls
Option Explicit
Event Timer()
Private WithEvents mTimer As Timer
Private intCount As Integer
Public Property Let Interval(ByVal intInterval As Integer)
mTimer.Interval = intInterval
End Property
Public Property Get Interval() As Integer
Interval = intInterval
End Property
Private Sub Class_Initialize()
mTimer.Enabled = True
Debug.Print "Initialized..."
End Sub
Private Sub mTimer_Timer()
intCount = intCount + 1
RaiseEvent Timer
End Sub
Public Sub Count()
Debug.Print intCount
End Sub
'Form1
Option Explicit
Private WithEvents mTimerObj As CTimer
Private Sub Form_Load()
Set mTimerObj = New CTimer
End Sub
Private Sub mTimerObj_Timer()
Debug.Print "Timer Event!"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mTimerObj = Nothing
End Sub
Now, what im trying to do is basically encapsulate the timer control inside a class, with a few extra properties.
When i run the above code, i get an error when the Class_Initialize() sub runs, saying "Object variable or With Block variable Not Set". Any ideas?
I want to do this without building a separate OCX. I have never really looked into ActivX before. Can anyone point me in the right direction?
Thanks in advance :)
Laterz