Solved

Slowly change colors of a label

Posted on 2002-05-07
2
177 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 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now