Can MULTIPLE CONTROLS trigger the same CODE?
2020-11-02-180830
All --
I have a APP with a large number of CHECKBOXES.
I would like the same routine to be triggered when the
checkBox1.CheckedChanged
is triggered.
The INTERNET says that I should be able to chain these .CheckChanged together and connect multiple events to a single event handler in Visual Basic as shown below with a BUTTON EXAMPLE.
<span>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click ' Add event-handler code here. End Sub </span>
I attempted this in CODE within the PROJECT WORKBENCH. The WORKBENCH does not like the list when it is connected by commas
Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) _ Handles checkBox1.CheckedChanged, checkBox2.CheckedChanged 'Debug.print "--- checkBox1_CheckedChanged CheckChangedWorker() End Sub
or when it is just separated by spaces
Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) _ Handles checkBox1.CheckedChanged checkBox2.CheckedChanged 'Debug.print "--- checkBox1_CheckedChanged CheckChangedWorker() End Sub
Is there a way to make the WORKBENCH HAPPY and to not have to have a
_CheckChanged
routine for each of the 24 checkboxes in this section of this APP call the CheckChangedWorker?
Thanks.
-- Matt
0
Answers
It is limitation of interpreted mode of Image-Pro scripting language, it can handle only one sender.
You can switch to Compiled mode and have full VB.NET compatibility, though you will not be able to debug your macros.
In compiled mode the following statement works:
I've also attached the test project.
Yuri