Results 1 to 8 of 8

Thread: Blinking Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344
    If i wanted lets say the text in a label to blink using a loop not a timer with the colors red and white.....how would i do that?
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    Member
    Join Date
    May 2000
    Posts
    41
    'create a label and a command button and stick this code in
    ' the command button then run to see it work.
    ' hope this helps!
    Dim intRed As Long
    Dim intWhite As Long
    ' next dim is optional for timeloop later on...
    Dim dtTimeLoop As Date

    intRed = vbRed
    intWhite = vbWhite
    Label1.ForeColor = intWhite
    Do While True
    If Label1.ForeColor = intWhite Then
    Label1.ForeColor = intRed
    Else
    Label1.ForeColor = intWhite
    End If

    DoEvents
    'optional timer to slow down color cycling
    dtTimeLoop = Time
    Do While Time <= DateAdd("s", 1, dtTimeLoop)
    DoEvents
    Loop
    'end of slowdown
    Loop
    Here I doeh again

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Doesn't Work

    Anyone have any ideas why it doesnt work?
    -RaY
    VB .Net 2010 (Ultimate)

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    This code from Matthew makes the form blink black and white

    Code:
    '[begin of code]
    'Author: Megatron and Matthew Gates(fixed and added code from Matthew)
    'Origin: Somewhere on the forums
    'Purpose: BlackToWhite, WhiteToBlack
    'Version: All VBs
    
    Private Sub BlackToWhite(frm As Form)
        For i = 0 To 255
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, i, i)
        Next i
    End Sub
    
    Private Sub WhiteToBlack(frm As Form)
        For i = 255 To 0 Step -1
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, i, i)
        Next i
    End Sub
    
    'Usage:
    
    'Call BlackToWhite(Me)
    '[end of code]
    I gotta go now so I'm not able to edit it for red and white on a lable, shouldn't be that hard!

    Oh, I now see that the code the other guy posted works!!! use that one instead!

    [Edited by Jop on 10-04-2000 at 01:52 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Blink(lbl As Label)
        For x = 1 To 500
            lbl.BackColor = vbWhite
            For i = 1 To 200
            DoEvents
            Next i
            lbl.BackColor = vbRed
            For i = 1 To 200
            DoEvents
            Next i
            
        Next x
    End Sub
    
    Private Sub Form_Click()
       Call Blink(Label1)
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    The code

    The code the first guy game me works fine, however it has to be in a command button.....if i do it on a form load my project never starts...
    -RaY
    VB .Net 2010 (Ultimate)

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Put it in form_Activate, not form_load, because the form wont show up until it exits the load event.
    I'm not sure but a command button doesn't support colored text, so you would have to make your own activeX or download one from somwhere, to do that.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Member
    Join Date
    May 2000
    Posts
    41
    'Would be easier with a timer but since you specifically
    'requested without it..do this...

    'create a label and stick this code in
    'form.activate (like kedeman said)
    '
    ' hope this helps!
    Dim intRed As Long
    Dim intWhite As Long
    ' next dim is optional for timeloop later on...
    Dim dtTimeLoop As Date

    intRed = vbRed
    intWhite = vbWhite
    Label1.ForeColor = intWhite
    Do While True
    If Label1.ForeColor = intWhite Then
    Label1.ForeColor = intRed
    Else
    Label1.ForeColor = intWhite
    End If

    DoEvents
    'optional timer to slow down color cycling
    dtTimeLoop = Time
    Do While Time <= DateAdd("s", 1, dtTimeLoop)
    DoEvents
    '!!!!!!! PUT YOUR CODE HERE
    ' your code goes here
    '

    '
    '!!!!!!! END OF YOUR CODE
    Loop
    'end of slowdown
    Loop

    Here I doeh again

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