Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making Button's flashing 2

Status
Not open for further replies.

BaDi

Programmer
May 14, 2002
32
0
0
NL
Hi!

Does anybody know how I can make specific button's flash by pushing a command - button?

Thanx in Advance!

 
Hi

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.

Hope this helps.

Cheers
 
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


 
By button has the collor Button Face

What is this in VB Language? Something like VbButtonFace or VbGray?

Thanx in advance!

 
You can use the hexadecimal color number: &H8000000F& for Button face. ie
cmdFlash.BackColor = &H8000000F&

Sorry, I don't know what the vb worded version is, or if there is one.
 
You can use the hexadecimal color number: &H8000000F& for Button face. ie
cmdFlash.BackColor = &H8000000F&

Sorry, I don't know what the vb worded version is, or if there is one.
 
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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top