|
-
October 5th, 2001, 03:22 AM
#1
Timer Events in Class Module
I am a VB beginner and hope somebody can give me some advice on the following matter:
I am working on a class module that is able to receive the following information:
Controlname: ie. lblInfo
background color of the control: ie. &H00C0FFFF&
foreground color of the control: ie. &H00FF0000&
desired background color: ie. frmData.background
desired foreground color: ie. frmData.background
The class has some internal code that breaks the colornumbers down to rgb colors and subsequently changes the current background and foreground colors of the control to the desired background and foreground colors. In the example above background and foreground color of the lblInfo control would fade to the background color of the frmData, which contains lblInfo.
The code for that is rather simple and works fine. The problem is that I would like to control the speed of the fading process. I don't like the side effects of API Sleep calls or DoWhile Loops with DoEvents. So I wonder if it is possible to use a timer event in a class module?
The following code is in the class module.
Declaration Section:
Private WithEvents Timer1 As betterTimer
...
Private Sub Class_Initialize()
Set Timer1 = New betterTimer
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
...
Public Sub Timer1_Timer
code for fading ...
End Sub
So it is possible to get a Sub Timer1_Timer into my class module, but if I call the sub from my main form:
Dim calc As New clsFade
calc.Timer1_Timer
then the programm runs through the Sub Timer1_Timer once and returns to the calling form. I guess that is to be expected. But what can I do to make the programm go over the code in the Timer routine at every timer interval until I set timer.enabled = False? Is it possible at all to do that in a class module?
Your help would be highly appreciated. Thank you.
Carl
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|