faire fonctionner plusieur Texte Clignotant

creolia

XLDnaute Impliqué
Bonsoir à tous j'ai trouver sur ce forum une macro pour un texte clignotant

Code:
Sub Label2()
Dim temps As Single
    
    temps = Timer
    
    Do
        Do Until temps1 + 0.5 <= Timer
            DoEvents
        Loop
        
        ' Si la couleur de fond du Label1 est rouge alors le fond du Label1 est noir
        ' sinon le fond du Label1 est rouge
        If UserForm1.Label2.BackColor = &H8000000E Then
            UserForm1.Label2.BackColor = &HFF&       ' Mettre la couleur que tu veux
        Else
            UserForm1.Label2.BackColor = &H8000000E
        End If
        temps1 = Timer
    Loop

End Sub

mais quand j'essais par le bias d'une checkbox faire clignoter plusieur sa m'arrete un pour agir sur l'autre comment puis je faire pour faire clignoter mes label selectionnner en meme temps

merci d'avance de votre aide et Bonne année à tous
 

Pièces jointes

  • Classeur1.xls
    33 KB · Affichages: 95
  • Classeur1.xls
    33 KB · Affichages: 106
  • Classeur1.xls
    33 KB · Affichages: 96

PMO2

XLDnaute Accro
Re : faire fonctionner plusieur Texte Clignotant

Bonjour,

Essayez la démarche suivante

1) copiez le code suivant dans un module standard

Code:
Public STOP_DO As Boolean

Sub Clignotement(Optional dummy As Byte)
Dim temps As Single
temps = Timer
With UserForm1
  Do
    If STOP_DO Then Exit Do
    Do Until temps + 0.5 <= Timer
      DoEvents
    Loop
    If .CheckBox1 Then
      With .Label1
        If .BackColor = &H8000000E Then
           .BackColor = vbRed
        Else
           .BackColor = &H8000000E
        End If
      End With
    End If
    If .CheckBox2 Then
      With .Label2
        If .BackColor = &H8000000E Then
           .BackColor = vbYellow
        Else
           .BackColor = &H8000000E
        End If
      End With
    End If
    If .CheckBox3 Then
      With .Label3
        If .BackColor = &H8000000E Then
           .BackColor = vbBlue
        Else
           .BackColor = &H8000000E
        End If
      End With
    End If
    temps = Timer
  Loop
  If STOP_DO Then
    .Label1.BackColor = &H8000000E
    .Label2.BackColor = &H8000000E
    .Label3.BackColor = &H8000000E
  End If
End With
End Sub


2) copiez le code suivant dans la fenêtre de code du UserForm

Code:
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "Stop" Then
  STOP_DO = True
  CommandButton1.Caption = "Relancer"
ElseIf CommandButton1.Caption = "Relancer" Then
  STOP_DO = False
  CommandButton1.Caption = "Stop"
  Application.OnTime Now + TimeValue("00:00:00"), "Clignotement"
End If
End Sub

Private Sub UserForm_Initialize()
STOP_DO = False
Application.OnTime Now + TimeValue("00:00:01"), "Clignotement"
CommandButton1.Caption = "Stop"
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
STOP_DO = True
End Sub


Cordialement.

PMO
Patrick Morange
 

Statistiques des forums

Discussions
312 361
Messages
2 087 626
Membres
103 608
dernier inscrit
rawane