I have a bunch of these and I'd rather send a single line to a sub than have a mile-long sub creating all of them.
This doesn't work. Msgbox returns "True" (Is Nothing). ???
.
But this works fine.Code:Private Sub CreateIndicator(ByRef Indicator As cIndicator, ByRef Picturebox As VB.Picturebox, ByRef Label As VB.Label, ByRef LabelPosition As LABEL_POSITION, ByRef Tooltip As String, ByRef IndicatorCollection As Collection) Set Indicator = New cIndicator ' Is valid while in this sub. Then not. With Indicator Set .Picturebox = Picturebox Set .CompanionLabel = Label .LabelPosition = LabelPosition .IgnoreClicks = True .TooltipText = Tooltip .Backcolor = &H404040 .OffColor = &H400000 .OnColor = &HC00000 .CompanionLabel.Fontsize = 8 .Refresh End With IndicatorCollection.Add Indicator End Sub Private Sub CreateIndicators() Dim m_Indicator As cIndicator Set colIndicators = New Collection Set colSwitches = New Collection CreateIndicator mw_Indicator_DND, picIndicator_DnD, lblIndicator_DnD, idx_LabelPosition_Left, "Do Not Disturb.", colIndicators MsgBox mw_Indicator_DND Is Nothing ' Returns True. ' <snip> end sub Private Sub CreateIndicator(ByRef Indicator As cIndicator, ByRef Picturebox As VB.Picturebox, ByRef Label As VB.Label, ByRef LabelPosition As LABEL_POSITION, ByRef Tooltip As String, ByRef IndicatorCollection As Collection) Set Indicator = New cIndicator With Indicator Set .Picturebox = Picturebox Set .CompanionLabel = Label .LabelPosition = LabelPosition .IgnoreClicks = True .TooltipText = Tooltip .Backcolor = &H404040 .OffColor = &H400000 .OnColor = &HC00000 .CompanionLabel.Fontsize = 8 .Refresh End With IndicatorCollection.Add Indicator End Sub
Code:Private Sub CreateIndicators() Dim m_Indicator As cIndicator Set colIndicators = New Collection Set colSwitches = New Collection Set mw_Indicator_DND = New cIndicator With mw_Indicator_DND Set .Picturebox = picIndicator_DnD Set .CompanionLabel = lblIndicator_DnD .LabelPosition = idx_LabelPosition_Left .TooltipText = "Do Not Disturb." End With colIndicators.Add mw_Indicator_DND <snip> For Each m_Indicator In colIndicators With m_Indicator .OffColor = &H400000 .OnColor = &HC00000 .Backcolor = &H404040 .IgnoreClicks = True .CompanionLabel.Fontsize = 8 .Refresh End With Next m_Indicator




Reply With Quote