changing the colour of a label in vba

Mcgrco

Registered User.
Local time
Today, 13:25
Joined
Jun 19, 2001
Messages
118
Im a trying to write a function which will change the colour of a label on mose moves. the sample code i have written is

Public Function funMouseBehaviour(strName As String, strAction As String)


Select Case strAction

Case "Down", "Up"


For Each ctl In Me.Controls

If strName = ctl.Name Then

Select Case strAction

Case "Down"
ctl.BorderStyle = 0
ctl.ForeColor = 16711680

Case "UP"
ctl.BorderStyle = 5
ctl.ForeColor = 16711680

End Select
End If
Next ctl

End Select

I want to call the function like so

Private Sub Label0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
X = funMouseBehaviour("label10", "UP")
End Sub

I cant get it to work.

Can anyone please help show me where im going wrong


Much appreciated
 
Not sure but emove the X = . To call a function you just need the function name and the parameters to pass to it.

Another point, not sure if Case is casesensitive. If it is then change the Up to UP or vice versa

HTH
 

Users who are viewing this thread

Back
Top Bottom