Solved

Slowly change colors of a label

Posted on 2002-05-07
2
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

733 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