Any way to set a common Property to the same thing for a bunch of objects?
Example(I know this is not going to work but it is the easiest way of representing my inquiry)
With BackColor = vbWhite
text1
form1
label1
End With
Quote from: 111787 on May 24, 2005, 03:33 PM
Any way to set a common Property to the same thing for a bunch of objects?
Example(I know this is not going to work but it is the easiest way of representing my inquiry)
With BackColor = vbWhite
text1
form1
label1
End With
I don't think you can do that specfically but you can always loop through all the controls you want and place some error handling and set the backcolor to the ones you want or all to white. Or specfify which ones you don't want to change.
I get it. Nope.
Text1.BackColor = vbWhite
Form1.BackColor = vbWhite
Label1.BackColor = vbWhite
Welcome, Nate, to Valhalla Legends forums!
Its got to be possible, everything is possible.
Quote from: Joex86] link=topic=11691.msg113634#msg113634 date=1116974163]
I get it. Nope.
Dim C As Control
Dim F As Form
For Each F In Forms
F.BackColor = vbBlack
For Each C In F
C.BackColor = vbBlack
Next C
Next F
Set C = Nothing
Set F = Nothing
You could also go further.
If (TypeOf C Is TextBox) Then
C.BackColor = vbBlack
ElseIf (TypeOf C Is Label) Then
C.BackColor = vbRed
End If
etc.
Very much thanks, this is now what i have so far. I put the error i get in as a comment.
Public Sub CommonProp(cpForm As Form, _
cpProperty As Variant, _
cpConstant As Variant, _
ParamArray cpObjects() As Variant)
Dim C As Control
Dim F As Form
Dim x As Integer
For Each F In Forms
If F = cpForm Then 'Type Mismatch
For Each C In F
For x = LBound(cpObjects) To UBound(cpObjects)
If C.Name = cpObjects(x) Then
C.cpProperty = cpConstant 'I doubt that will work
End If
Next x
Next C
End If
Next F
Set C = Nothing
Set F = Nothing
End Sub
Quote from: 111787 on May 24, 2005, 03:33 PM
Any way to set a common Property to the same thing for a bunch of objects?
Example(I know this is not going to work but it is the easiest way of representing my inquiry)
With BackColor = vbWhite
text1
form1
label1
End With
Text1.BackColor = Form1.BackColor = Label1.BackColor = vbBlack