Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>modal, modeless, and default forms do show up in the forms collection</p> <p>run the following test project to see it happening :</p> <pre><code>'project with 2 forms ' form1 with : ' 1 label: name=Label1 ' 1 timer: name=Timer1 ' 4 command buttons: names are Command1, Command2, Command3, Command4 ' form2 with nothing on it Option Explicit Private Sub Command1_Click() Dim frm As New Form2 frm.BackColor = vbRed frm.Show vbModal End Sub Private Sub Command2_Click() Dim frm As New Form2 frm.BackColor = vbGreen frm.Show vbModeless, Me End Sub Private Sub Command3_Click() Dim frm As New Form2 frm.Show End Sub Private Sub Form_Load() With Screen Move .Width / 2, 0, .Width / 2, .Height / 2 End With 'Screen Command1.Caption = "modal" Command2.Caption = "modeless" Command3.Caption = "default" Command4.Caption = "unload" With Timer1 .Interval = 1000 .Enabled = True End With 'Timer1 End Sub Private Sub Form_Resize() Dim sngLblWidth As Single, sngLblHeight As Single Dim sngCmdWidth As Single, sngCmdHeight As Single sngCmdHeight = 495 sngLblHeight = ScaleHeight - sngCmdHeight sngLblWidth = ScaleWidth sngCmdWidth = sngLblWidth / 4 Label1.Move 0, 0, sngLblWidth, sngLblHeight Command1.Move 0, sngLblHeight, sngCmdWidth, sngCmdHeight Command2.Move sngCmdWidth, sngLblHeight, sngCmdWidth, sngCmdHeight Command3.Move 2 * sngCmdWidth, sngLblHeight, sngCmdWidth, sngCmdHeight Command4.Move 3 * sngCmdWidth, sngLblHeight, sngCmdWidth, sngCmdHeight End Sub Private Sub Timer1_Timer() Dim frm As Form Dim strShow As String strShow = CStr(Now) For Each frm In Forms strShow = strShow &amp; vbCrLf &amp; frm.Name Next frm Label1.Caption = strShow End Sub </code></pre> <p><strong>[EDIT]</strong></p> <p>add 3 command buttons to form2 and click them to test what happens upon unloading</p> <p>test it while running from the ide and notice the difference when a modal form is shown, when the modeless form is shown (with owner), and when a default form is shown (without owner) .. pay attention to the 'run' button i the ide .. when unloading form1 with a model form shown, the application remains running</p> <p>here is the code for Form2</p> <pre><code>Option Explicit Private Sub Command1_Click() UnloadForms "Form1" End Sub Private Sub Command2_Click() UnloadForms "Form2" End Sub Private Sub Command3_Click() UnloadForms "" End Sub Private Sub Form_Load() Command1.Caption = "Unload Form1" Command2.Caption = "Unload Form2" Command3.Caption = "Unload All" End Sub Private Sub UnloadForms(strName As String) Dim frm As Form For Each frm In Forms If InStr(frm.Name, strName) &gt; 0 Then Unload frm End If Next frm End Sub </code></pre> <p><strong>[EDIT 2]</strong></p> <p>below is the sub which i use to unload all my forms, this sub is in a module so i can call it everywhere</p> <pre><code>Public Sub UnloadAll(strExcept As String, blnKeepMDI As Boolean) Dim frm As Form 'unload all other forms For Each frm In Forms Select Case frm.Name Case "mdiPaneel" 'unload mdi as last Case "frmMsg" 'dont unload msg unless specified Case strExcept 'dont unload this if mdi stays If blnKeepMDI = False Then Unload frm End If Case Else Unload frm End Select Next frm If blnKeepMDI = False Then 'unload mdi and finish program Unload mdiPaneel End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload