Search Tools Links Login

Label Flash


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

Original Author: Brett Raven

Inputs

Label by reference, number of flash cycles, flash colour.

Assumptions

The Timer object

Returns

Nothing.

Side Effects

None.

Code

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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 70 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.