我面临一个多表单应用程序的问题,我有 mainForm 和几个 mdiForms。其中一个子表单 (frmDashboardManager) 是在 mainForm 之外打开新的拥有表单 (frmDahboard) 这是我所拥有的:
Dim fDash As New frmDashboard
fDash = isDashboardOpen(tempDash)
If fDash IsNot Nothing Then
fDash.Close() 'HERE I GET THE ERROR
End If
Private Function isDashboardOpen(ByVal dash As clsDashboard) As frmDashboard
isDashboardOpen = Nothing
Try
'search if Dashboard is already open
For Each fr As frmDashboard In Me.OwnedForms
If fr.My_Dashboard.Id = dash.Id Then
isDashboardOpen = fr
Exit For
End If
Next
Catch ex As Exception
gError.GetAppEx(ex, FORM_NAME & ".isDashboardOpen")
Finally
End Try
End Function
我得到的错误是:对象引用未设置为对象的实例。
疯狂的是,我检查了 isDashboardOpen 实际上返回了一个 frmDashboard(这也是执行 fDash.Close() 的原因)。有任何想法吗?
谢谢