I acheived this by adding a timer and a couple of buttons. The button you intend to make flash must have its Style property set to 1 - Graphical. Once you have done this you can add the button that when you click this makes the other button flash by using code like this.
----------------------------------------------
Private Sub Command1_Click()
Timer1.Interval = 250
End Sub
Private Sub Timer1_Timer()
If cmdFlash.BackColor = vbRed Then
cmdFlash.BackColor = vbBlue
Else
cmdFlash.BackColor = vbRed
End If
End Sub
----------------------------------------------
This will make a button named cmdFlash flash blue and red. You can change the speed of the flash by changing the timer interval and obviously the colours by changing the constants.
You may also want to turn the flash off. Continuiing with NevG's code, lets set during design, the enabled property of Timer1 to False, so that when the program first starts up, the cmdFlash button is not flashing. By adding the one bold line below, Command1 will not function as a toggle. The first time you pressit, the flash begins, the second time is stops - third time on ....
Private Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled
Timer1.Interval = 250
End Sub
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
Badi,
In design mode, pull up the properties for a button. First thing you should do is to change the .Style property to 1-Graphical - selected from the pull down for that property.
Then go to the BackColor property. You have two tabs - System and Palette. Choose Palette, then choose whatever color you wish.
Then at run time, you can set the BackColor to any color you wish. You may use either a hex number, or one of the predefined color constants.
To use a hex number, the format would be as follows:
&Hbbggrr
where bb represents the Blue, valid values are 00 to FF
where gg represents the Green, valid values are 00 to FF
and rr represents the Red, valid values are 00 to FF
To use one of the color constants
cmdFlash.BackColor = vbGreen
cmdFlash.BackColor = vbYellow
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.