|
-
Nov 26th, 2008, 06:40 AM
#1
Thread Starter
New Member
[RESOLVED] Flashing text
Hey,
I have tried putting a timer on the form, and put a timer.tick sub routine to change the colour of the text but no sucess please may someone help me
Thanks,
Mike
-
Nov 26th, 2008, 07:01 AM
#2
Hyperactive Member
Re: Flashing text
 Originally Posted by Surfymike
Hey,
I have tried putting a timer on the form, and put a timer.tick sub routine to change the colour of the text but no sucess please may someone help me
Thanks,
Mike
did u already set the timer's interval?
try this:
Code:
Text1.Forecolor = Rnd * RGB (123,123,123)
"More Heads are Better than One"
-
Nov 26th, 2008, 08:48 AM
#3
Re: Flashing text
Welcome to the forums. 
 Originally Posted by Surfymike
I have tried putting a timer on the form, and put a timer.tick sub routine to change the colour of the text but no sucess please may someone help me
Post what you did.
-
Nov 26th, 2008, 09:20 AM
#4
Re: Flashing text
 Originally Posted by Surfymike
Hey,
I have tried putting a timer on the form, and put a timer.tick sub routine to change the colour of the text but no sucess please may someone help me
Thanks,
Mike
Timer.Tick in VB6 ?? 
Are you using the timer control that ships with VB6 or some third party control?
-
Nov 26th, 2008, 11:11 AM
#5
Re: Flashing text
 Originally Posted by Pradeep1210
Timer.Tick in VB6 ?? 
Are you using the timer control that ships with VB6 or some third party control?
Perhaps this would have been .Net instead?
-
Dec 2nd, 2008, 04:42 AM
#6
Thread Starter
New Member
Re: Flashing text
im using the VB6 timer and i thought timer.tick is a valid sub routine where it executes whenever the interval has been reached
-
Dec 2nd, 2008, 04:48 AM
#7
Thread Starter
New Member
Re: Flashing text
i have set the timers interval and put the code in and no luck
-
Dec 2nd, 2008, 04:49 AM
#8
Thread Starter
New Member
Re: Flashing text
I have tried:
Private Sub Timer1_Timer()
Text3.ForeColor = Rnd * RGB(123, 123, 123)
End Sub
and
Private Sub Timer1_Tick()
Text3.ForeColor = Rnd * RGB(123, 123, 123)
End Sub
-
Dec 2nd, 2008, 05:01 AM
#9
Re: Flashing text
Try this:
vb Code:
Private Sub Timer1_Timer() Text3.ForeColor = RGB(Rnd *123, Rnd * 123, Rnd * 123) End Sub
-
Dec 2nd, 2008, 05:12 AM
#10
Thread Starter
New Member
Re: Flashing text
grim,
still no luck, im pretty new to timers so what do i need on the form load for timer to check if its the timer or the code?
-
Dec 2nd, 2008, 05:52 AM
#11
Re: Flashing text
vb Code:
Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = True End Sub
-
Dec 2nd, 2008, 12:26 PM
#12
Re: Flashing text
You could put in a BreakPoint in your Timer event so you could check if it is firing or not.
-
Dec 3rd, 2008, 05:42 AM
#13
Thread Starter
New Member
Re: Flashing text
have put the interval in and put it to enabled and still nothing,
what is a break point?
and you think its the timer code thats wrong or the code that is making the text flash
-
Dec 3rd, 2008, 05:58 AM
#14
Re: Flashing text
A break point is an essential debugging tool.
In VB when you are in a code module you will see, to the left of the white area you type you code in, a grey bar about 1cm thick.
If you click in that grey area on the same line of some code it will enter a break point (the code line will now be highlighted), when you run you code from now on it will stop at the break point and allow you to step through your code using the F8 button to see what is happening.
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Dec 3rd, 2008, 06:06 AM
#15
Thread Starter
New Member
Re: Flashing text
Thanks for telling me bout the break point,
its doing the sub however the text is not changing,
so can you help me develop the actual code that makes it flash/change colour
thanks
-
Dec 3rd, 2008, 06:35 AM
#16
Thread Starter
New Member
Re: Flashing text
i put the interval at 10 and now it sort of changes colour but was wanting it t flash rather than change colour any ideas?
-
Dec 3rd, 2008, 06:38 AM
#17
Re: Flashing text
increase interval to 100 or 1000 (1000=1 sec)
-
Dec 3rd, 2008, 06:38 AM
#18
Re: Flashing text
right the timer control is fairly simple. add the following code to a Form.
vb Code:
Private Sub Form_Load() Timer1.Interval = 10000 'interval in milliseconds 10000 = 10 seconds Timer1.Enabled = True End Sub Private Sub Timer1_Timer() 'this will fire after 10 seconds !! MsgBox "10 seconds reached" 'do stuff End Sub
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Dec 3rd, 2008, 06:40 AM
#19
Re: Flashing text
to get it to flash just set you interval lower to say 1 second (1000)
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Dec 3rd, 2008, 06:41 AM
#20
Re: Flashing text
right, i have just looked and seen i have just repeated what Pradeep posted concerning the timer !!
So you don't need to change anything, just the Interval setting to 1000 !
Please Mark your Thread "Resolved",  if the query is solved & Rate those who have helped you
-
Dec 3rd, 2008, 06:47 AM
#21
Thread Starter
New Member
Re: [RESOLVED] Flashing text
it works thanks everyone for helping 
i shall be giving good feedback
-
Dec 3rd, 2008, 10:03 AM
#22
Re: [RESOLVED] Flashing text
Surfymike
FWIW, "flash" is a somewhat vague word in this context.
One possible meaning could be that the text alternates
between being visible, and not being visible (ie, on-off).
Another is that it alternates between colors (say, red-black).
Another is that it alternales between boldface and normal.
If any of the above are appealing, then you might consider
using the Mod function. If, for example, you have settled
on a 1 second interval, then, if the second is even, the
text could be "on", and if the second is odd, the text
could be "off".
You've indiciated that you've resolved this, but if the
above is appealing but confusing, holler.
Spoo
-
Dec 3rd, 2008, 02:57 PM
#23
Re: [RESOLVED] Flashing text
Surfymike:
A little birdie told me you might be interested
These two code frags are from Pradeep1210
Code:
Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Text3.ForeColor = RGB(Rnd *123, Rnd * 123, Rnd * 123)
End Sub
To have the text alternately flash red|black, you could modify
the second sub as follows:
Code:
Private Sub Timer1_Timer()
sec = Second(Now)
resu = sec Mod 2
If resu = 0 Then
Text3.ForeColor = vbRed
ElseIf resu = 1 Then
Text3.ForeColor = vbBlack
Endif
End Sub
.. where:
Now is a function that returns your computer's system date/time,
Second is a function that returns an integer from 0 to 59, ie, the seconds portion of the time.
Mod is an operator that divides 2 numbers and returns only the remainder.
Here, I have used "sec" and "2".
-- if sec is even, resu = 0
-- if sec is odd, resu = 1.
This, then, enables the ForeColor branches to execute as desired.
With some tinkering, you could get the following results:
-- text is visible|not visible (on|off)
-- text is bold|normal
-- flashing happens more|less rapidly
HTH
Spoo
Last edited by Spoo; Dec 3rd, 2008 at 03:02 PM.
-
Dec 4th, 2008, 01:43 AM
#24
Re: [RESOLVED] Flashing text
 Originally Posted by Spoo
...
To have the text alternately flash red|black, you could modify
the second sub as follows:
Code:
Private Sub Timer1_Timer()
sec = Second(Now)
resu = sec Mod 2
If resu = 0 Then
Text3.ForeColor = vbRed
ElseIf resu = 1 Then
Text3.ForeColor = vbBlack
Endif
End Sub
...
HTH
Spoo
It could have been even easier. Since you are looking at only 2 values, a boolean is more suited for it. Why go round and round to achieve a simple thing.
Code:
Private Sub Timer1_Timer()
Static resu As Boolean
resu = Not resu
Text3.ForeColor = IIf(resu, vbRed, vbBlack)
End Sub
Pradeep
-
Dec 4th, 2008, 01:20 PM
#25
Re: [RESOLVED] Flashing text
Pradeep
The main reason I chose to go round and round was that I was not
familiar with Static
I read up a little on it, but must confess to still being rather confused
by its purpose. No doubt, your code is much more efficient than my
previous post.
Be that as it may, would the following accomplish the same thing?
in declarations:
Code:
Public resu as Boolean
..then, the timer sub:
Code:
Private Sub Timer1_Timer()
resu = Not resu
Text3.ForeColor = IIf(resu, vbRed, vbBlack)
End Sub
As the time sub will repeatedly trigger, is it not even more efficient
to remove the Static line altogether (and put it in the
declarations, where it executes only one time)?
Am I missing something? As I say, I'm not quite sure of the benefit
of the Static statement.
Spoo
-
Dec 4th, 2008, 02:37 PM
#26
Re: [RESOLVED] Flashing text
Static variable inside a procedure (sub or function) is just like a class/form level variable but the scope is that procedure only. It is not visible outside the procedure. However it will retain its values just like any other class/form level variable between subsequent calls to the procedure.
Pradeep
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
|