[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Slowly change colors of a label

Posted on 2002-05-07
2
Medium Priority
?
188 Views
Last Modified: 2010-05-02
Hi, how would I possibly take a label with the text color being white and slowly fade it to be red text when the user moves the mouse over it?  If at all possible, I would like to do it without using a timer.  Thanks.
0
Comment
Question by:jonnyfunfun
2 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 200 total points
ID: 6995337
Without a timer it becomes much more difficult, and ultimately it needs a timing mechanism to control the rate of progress.

I'd recommend this:

Add a timer, Timer1, with interval=100 and enabled=false, then add this code:

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Not Timer1.Enabled Then
    Label1.BackColor = vbWhite
    Timer1.Enabled = True
  End If
End Sub

Private Sub Timer1_Timer()
  Dim lCurrentColor As Long
  lCurrentColor = Label1.BackColor
  lCurrentColor = lCurrentColor - CLng(8 * CLng(256 ^ 2)) - CLng(8 * 256)
  If lCurrentColor <= 0 Then
    Timer1.Enabled = False
    Label1.BackColor = vbRed
  Else
    Label1.BackColor = lCurrentColor
  End If
End Sub
0
 
LVL 22

Expert Comment

by:cookre
ID: 6995455
How about changing the lable to a graphic that you replace with an animated GIF when you detect mouse over?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question