我怎样才能知道除了我正在工作的表单之外的表单是打开还是关闭的?
Visible
property (noting that doing so for an unloaded form will cause it to become loaded). For the loading state unfortunately there is no property. You have to iterate over all forms, and look whether your form is contained in the list of loaded forms:
Public Function IsFormLoaded(FormToCheck As Form) As Boolean
Dim F As Form
For Each F In Forms
If F Is FormToCheck Then
IsFormLoaded = True
Exit Sub
End If
Next
End Sub
全局集合Forms
包含当前加载的所有窗体。
您可以搜索表单集合
Dim aForm
For Each aForm In Forms
If aForm Is Form1 Then
MsgBox "Found Form1"
End If
Next