Results 1 to 3 of 3

Thread: Text Flash

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344
    How would I make a label flash red and white for 4 seconds? Prefer loop, but if know a timer way just through it on anyway.
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Here's an example whitout a Timer object.
    Code:
        Dim t As Single
        Dim blnColor As Boolean
        Dim lngCounter As Long
        
        t = Timer
        Do While Timer < t + 4
            lngCounter = lngCounter + 1
            If lngCounter = 20000 Then
                lngCounter = 0
                blnColor = Not blnColor
                Label1.ForeColor = IIf(blnColor, vbRed, vbWhite)
            End If
            DoEvents
        Loop

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This code does not need to have a timer object on the form. Change PAUSE to make the label flash at a different speed
    Code:
        Dim dblClock As Double
        Dim dblLastChange As Double
        Const PAUSE = 0.25 ' Flash every 1/4 second
        
        dblClock = Timer
        While Timer < dblClock + 4
            If dblLastChange + PAUSE < Timer Then
                dblLastChange = Timer
                If Label1.BackColor = vbRed Then
                    Label1.BackColor = vbWhite
                Else
                    Label1.BackColor = vbRed
                End If
            End If
            DoEvents
        Wend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width