Current location - Training Enrollment Network - Early education courses - How does VB make font colors change automatically and regularly?
How does VB make font colors change automatically and regularly?
It can be realized by a timer.

In the following code example, the font color in the Label changes to red, yellow and blue in turn regularly.

Model: form 1, Timer 1, Label 1.

Private Sub-Form _Load ()

Timer 1. "Interval = 500" starts the timer and sets the trigger interval to 0.5 seconds.

End joint

Private sub-timer 1_Timer ()

If 1 is marked. If the label font color is red, it is "Forecolor = vbredthen".

Label 1. "Forecolor = vbyellow" turns yellow.

Else if tag 1. Forecolor = vbyellowthen' If it is yellow.

Label 1。 "ForeColor = vbBlue" turns blue.

other

Label 1。 Forecolor = vbred' If it is any other color, it will turn red; So as to realize the alternation of red, yellow and blue.

If ... it will be over.

End joint