在将VB6代码转换为VB.NET的过程中,我需要替换以下代码,这些代码旨在关闭应用程序中剩余的所有打开的表单. 'close all sub formsFor i = My.Application.OpenForms.Count - 1 To 1 Step -1 'UPGRADE_ISSUE: Unload
'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
我已经用Close替换了Unload函数(如TFM所示),但是编译器抱怨OpenForms不是My.Application的成员.
我在哪里可以访问开放表格?
OpenForms属性返回FormCollection.您可以遍历集合来处理所有表单.For each f as Form in My.Application.OpenForms f.Close() Next