I have a problem with my sw: i have three forms: the main form(A), a secondary form (B) and third form (C). The form A must be always visibile and usable, the form B opening from form A and the form C opening form the form B. I need to open multiple instance of form C (i do not know how much instance are), i'm using this code in a command button on form B:
Dim newform As New modifica_normale
newform.LoadOrders(commessa_da_modificare, id_da_modificare, False)
newform.Show()
When the form B is close i need to close all of multiple instance of form C, so in the closing event i've tried to put:
modifica_normale.Close()
but do not work. I know that i can define newform as global variable and call newform.close(), but i don't know the number of newform that the user will open.
Thanks, Pietro.
This code will only close the common instance of the form and not each newly instantiated form object:
Instead you could try adding the forms to a forms collection as you create each form. Create a form level list on form B.
Add to it each time an instance of form C is created
When you want to close them, loop back through the forms collection closing each instance.