How can i know if one of the Form of the project has been loaded ?
I tried someting like
If MyForm Is Nothing Then ..
but it dosen't work
Thanks
Printable View
How can i know if one of the Form of the project has been loaded ?
I tried someting like
If MyForm Is Nothing Then ..
but it dosen't work
Thanks
Are you using MDI forms or MDI child forms? If so, you can cycle through the forms collection to see if a specific form is loaded.
'Here's some sample code
Dim iIndex As Integer
For iIndex = 0 To Forms.Count - 1
If (Forms(iIndex).Name = "frmYourForm") Then
MsgBox Forms(iIndex).Caption
End If
Next iIndex
Forms Collection is the best method.
Because VB keeps a global instance of the Form (with the same name ). So -
If MyFormName iS Nothing - will always be false, because there always exists a form by name 'MyFormName'. Typically what people do is not refer this Global form.
You could do something like this also:
dim lpForm as Form
...
set lpForm = New MyFormName
..else where
' check if an instance is loaded:
if lpForm Is nothing then
Set lpForm = New MyFormName
end if
' use the properties ..
lpForm.SomeProperty = SomeValue
RK