Brent,
As Furgus suggested the array of Delegates is how you get an array of
procedures.
Delegate Sub PanelSelected()
Dim Procedure_Panel_Selection() As PanelSelected = _
{ _
AddressOf Procedure_Panel_One_Selected, _
AddressOf Procedure_Panel_Two_Selected, _
AddressOf Procedure_Panel_Three_Selected _
}
Remember that arrays are zero based:
Procedure_Panel_Selection(0).Invoke()
Will execute Procedure_Panel_One_Selected.
Note:
> If Selection_Variable = 1 then
> Procedure_Panel_One_Selected
> Else
> If Selection_Variable = 2 then
> Procedure_Panel_Two_Selected
> Else
>
> etc....
> End If
> End If
>
Also Select Case or ElseIf both simplify your selection statement.
Select Case Selection_Variable
Case 1
Procedure_Panel_One_Selected
Case 2
Procedure_Panel_Two_Selected
End Select
If Selection_Variable = 1 Then
Procedure_Panel_One_Selected
ElseIf Selection_Variable = 2 Then
Procedure_Panel_Two_Selected
ElseIf Selection_Variable = 3 Then
Procedure_Panel_Three_Selected
End if
However my concern is you really need Polymorphism. Is the initialization
code largely the same for each panel or unique for each panel?
I would consider creating one or more new classes that are derived from
Panel that has the initialization code in the constructor of this new class.
Depending on how unique this initialization code is, I would have custom
properties, a custom event, or multiple derived classes for the unique code.
Applying OOP principles to simplify the code.
Hope this helps
Jay
"Brent McIntyre" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
> Good evening all,
>
> I am trying to set-up an array of procedures, which HELP informs me is
> impossible, so as a secondary idea I thought I could set up an array of
> initializing an event, which I also seem unable to do.
>
> What I am basically trying to do, is set-up an array that can somehow
> initialize procedures, as I have nearly two-hundred panels I need to
> cycle through and I don't want to use an extended IF Statement.
>
> Any help you may be able to provide would be much appreciated. Please
> see the example below of what I am basically trying to do.
>
> Yours sincerely,
>
> Brent McIntyre
>
>
> EXAMPLE of current set-up
>
> If Selection_Variable = 1 then
> Procedure_Panel_One_Selected
> Else
> If Selection_Variable = 2 then
> Procedure_Panel_Two_Selected
> Else
>
> etc....
> End If
> End If
>
> EXAMPLE of what I would like
>
> Procedure_Panel_Selection(1) ' Which would the run
> Procedure_Panel_One_Selected
>
> This takes a lot less code and can allow me to make my code easier for
> others to read and understand.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!