Results 1 to 9 of 9

Thread: Blinking label...

  1. #1
    Guest
    Code:
    Sub BlinkLbl(lbl As Label)
        Do
            Start = Timer
            
            Do While Timer < Start + 0.25
            DoEvents
            Loop
            
            lbl.Visible = Not lbl.Visible
        Loop
    End Sub
    
    Private Sub Command1_Click()
        BlinkLbl Label1
    End Sub

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90
    Decepticon? What does that mean? More than a Guru?
    ;-)

    Thanks, in fact this code works well!
    Bye!

  3. #3
    Guest
    Your Welcome. It's also possible to do this with the SetTimer API, but why use API when this function just the job just as good.

    Yeah, you get to choose your own title when you pass 4k.

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    A couple of enhancements to your code, so that the Do Loop will stop and the form will be unloaded when the app is ended....

    Code:
    Sub BlinkLbl(lbl As Label)
        Do Until DoEvents = 0
            Start = Timer
            
            Do While Timer < Start + 0.25
            DoEvents
            Loop
            
            lbl.Visible = Not lbl.Visible
        Loop
    End Sub
    
    Private Sub Command1_Click()
        Call BlinkLbl(lbl)
        Unload Me
    End Sub
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    In DOS it was much easier to do this!
    Sometimes it is also necessary to refresh the label after setting the Visible property of the Label control

  6. #6
    Guest
    Refresh it? I don't think you'd need to do that after you change its Visible property.

  7. #7
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Unfortunately Yes, Meg.
    Often, when working with my applications I ask myself the question "Hey, where is my label control?".
    When debugging the code and getting the Visible property of the control, it's should be really visible, but I don't see it. When using the Refresh method after setting the Visible property, everything works fine. strange, but that happens sometimes...

  8. #8
    Guest
    I've worked with VB for over 5 years and I've never has this problem. Perhaps it's just a bug in VB6, because I've used VB3, 4 and 5, but never encountered this.

  9. #9
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    I encounter this in VB3. It also happens sometimes (not often as I said) when changing the Caption property.

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