Advertisement
2002VB Miscellaneous #20364

Label Flash

Flash a label and its caption between starting forecolour and colour of your choice.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Private Sub Command1_Click()
  LabelFlash Me.Label1, 5, vbBlack
End Sub
Private Sub Form_Load()

  Me.Label1.ForeColor = vbWhite
  
End Sub
Public Function LabelFlash(ByRef lblLabel As Label, _
              ByVal lngCycles As Integer, _
              ByVal lngOffColour As Long) As Integer
  Dim lngOnColour   As Long
  Dim lngStart    As Long
  Dim lngTick     As Long
  Dim lngX      As Long
  
  ' Get the starting colour
  lngOnColour = lblLabel.ForeColor
  
  ' Get the starting time rounded to seconds
  lngStart = Round(Timer, 0)
  
  DoEvents
  While Not Round(Timer, 0) > (lngStart + lngCycles)
    If Round(Timer) > lngTick Then 'only kick over if a second has passed
      DoEvents
      ' Swap the on and off colours
      lblLabel.ForeColor = IIf(lblLabel.ForeColor = lngOffColour, lngOnColour, lngOffColour)
      lngTick = Round(Timer, 0)
    End If
  Wend
  ' Go Back to original colours
  lblLabel.ForeColor = lngOnColour
  
End Function
Commenti originali (3)
Recuperato da Wayback Machine