Unload Multiple Forms?

Unload Multiple Forms?



When I exit the main form, I would like for the other forms to close down at the same time.


Comments

  • : Unload Multiple Forms?

    :

    : When I exit the main form, I would like for the other forms to close down at the same time.

    :



    Add this sub to your main form:



    Private Sub Form_Unload(Cancel As Integer)

    Dim i As Integer



    'close all sub forms

    For i = Forms.Count - 1 To 1 Step -1

    Unload Forms(i)

    Next

    End Sub


  • It works, but before I unload my main form, I am trying to store my values in my txtboxes into the registry. Now it does not work. Would you happen to know how to correct this problem?



    Here's the code:



    Private Sub Form_Unload(Cancel As Integer)

    IPSi = txtIPSi(0).Text

    IPSm = txtIPSm(1).Text





    MSVi = txtMSVi(0).Text

    MSVm = txtMSVm(1).Text



    MCVi = txtMCVi(0).Text

    MCVm = txtMCVm(1).Text



    SaveSetting TsmReg, "Values", "IPSi", IPSi

    SaveSetting TsmReg, "Values", "IPSm", IPSm

    SaveSetting TsmReg, "Values", "MCVi", MCVi

    SaveSetting TsmReg, "Values", "MCVm", MCVm

    SaveSetting TsmReg, "Values", "MSVi", MSVi

    SaveSetting TsmReg, "Values", "MSVm", MSVm



    Dim i As Integer



    'close all sub forms

    For i = Forms.Count - 1 To 1 Step -1

    Unload Forms(i)

    Next

    End Sub








  • : Unload Multiple Forms?

    :

    : When I exit the main form, I would like for the other forms to close down at the same time.

    :



    For Each Form In Forms

        Unload Form

    Next


  • I tried this.



    I get an error saying "Variable required, can't assign this expression".



    : : Unload Multiple Forms?

    : :

    : : When I exit the main form, I would like for the other forms to close down at the same time.

    : :

    :

    : For Each Form In Forms

    : Unload Form

    : Next

    :






  • : I tried this.

    :

    : I get an error saying "Variable required, can't assign this expression".

    :

    Sorry about that, I forgot a line.



    Dim frm As Form



    For Each frm In Forms

        Unload frm

    Next



    This doesn't save any settings, you'll have to do that yourself.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories