|
-
Oct 4th, 2000, 08:10 AM
#1
Thread Starter
Hyperactive Member
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)
-
Oct 4th, 2000, 08:59 AM
#2
Member
'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
-
Oct 4th, 2000, 11:20 AM
#3
Thread Starter
Hyperactive Member
Doesn't Work
Anyone have any ideas why it doesnt work?
-RaY
VB .Net 2010 (Ultimate)
-
Oct 4th, 2000, 12:05 PM
#4
Frenzied Member
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.
-
Oct 4th, 2000, 12:19 PM
#5
_______
<?>
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
-
Oct 5th, 2000, 06:24 AM
#6
Thread Starter
Hyperactive Member
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)
-
Oct 5th, 2000, 06:32 AM
#7
transcendental analytic
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.
-
Oct 5th, 2000, 09:51 PM
#8
Member
'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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|