How do I uninstall all open forms in VB.NET?

In the process of converting VB6 code to VB.NET, I need to replace the following codes, which are designed to close all open forms remaining in the application.

'close all sub forms
For i = My.Application.OpenForms.Count-1 To 1 Step -1
'UPGRADE_ISSUE: Unload Forms() was not upgraded. Click for more:'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="875EBAD7-D704-4539-9969-BC7DBDAA62A2"'
Unload(My. Application.OpenForms(i))
Next i

I have replaced the Unload function with Close (as shown in TFM), but the compiler complains that OpenForms is not a member of My.Application.

Where can I access the open form?

The OpenForms property returns FormCollection. You can traverse the collection to process all forms.

For each f as Form in My.Application.OpenForms
f.Close()
Next

In the process of converting VB6 code to VB.NET, I need to replace the following codes, which are designed to close all open forms remaining in the application.

< pre>‘close all sub forms
For i = My.Application.OpenForms.Count-1 To 1 Step -1
‘UPGRADE_ISSUE: Unload Forms() was not upgraded. Click for more:’ms- help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword=”875EBAD7-D704-4539-9969-BC7DBDAA62A2″‘
Unload(My.Application.OpenForms(i))
Next i

I have replaced the Unload function with Close (as shown in TFM), but the compiler complains that OpenForms is not a member of My.Application.

Where can I access Open sheet?

The OpenForms property returns FormCollection. You can traverse the collection to process all forms.

For each f as Form in My.Application.OpenForms
f.Close()
Next

Leave a Comment

Your email address will not be published.