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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing component properties in module. 2

Status
Not open for further replies.

BaDi

Programmer
May 14, 2002
32
0
0
NL
Hi!

I have a timer that makes my components Flash:

inititalisation:

Private sub Button1_click()
Flash_ID = 1
Flash_Timer.Enabled = True
Flash_Timer.Interval = Flash_Interval
End sub

Private Sub Flash_Timer_Timer()
MakeFlash (Flash_ID)
End Sub

MakeFlash is a sub that is placed in a module.
In this sub it checks the value of Flash_ID so that it knows what to do.

eg.:

Case 1
If frmMain.Button1.BackColor = &H8000000F Then
frmMain.Button1.BackColor = vbRed
Else
frmMain.Button1.BackColor = &H8000000F
End If

frmMain is the name of the form where my components are placed.

My buttons don't flash!! If I place this code on the form it works. What do I need to do?

Thanx in advance!
 
If I get you right frmMain is the name of the form that you are using (i.e. frmMain.frm). In that case, when you call from the moudule to frmMain.<something>, it doesn't reffer to your frmMain, but to a new instance of the frmMain (you can check it by putting a breakpoint in the Form_Initialize event of the frmMain - if it gets to the breakpoint from the sub it means that it creates a new instance of the form).
You should send to the sub as a parameter the form - makeflash will get a VB.Form as a parameter and you will send to it Me.

Hope I helped.

Naftali.
 
Thanx! That was very helpfull! Now I would like to put the color vbRed in a constant value that will be used through the entire module.. so that I can easily change the value at one place only.
How do I put this value in a const.. &quot;vbRed&quot; doesnt work..

Thanx in advance!
 
Private Sub Command1_Click()
Dim Button As CommandButton
Const Color As String = vbRed


For Each Button In Me.Controls
Button.BackColor = Color
Next
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top