?
Solved

Slowly change colors of a label

Posted on 2002-05-07
2
Medium Priority
?
186 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 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

Independent Software Vendors: 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

770 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