I am using VB.Net 2003 (version 1.1) and I am attempting to open some forms with:

Dim myform As New FormX

If myform.Visible = False Then
    myform.Show
End If

Problem is, no matter what, a New instance of the form opens. How do I check if an instance of myform is already open?

Thank You
major_lost (but improving thanks to you all!)

Recommended Answers

All 5 Replies

According to ur code u r creating the new instance of the FormX and then checking the condition.....

if u know the form name then just give the name and then the condition...dont create an instance...

Ok, here's the deal... When I attempt to use the form name, I do NOT get the option to open my form. I have to declare it somewhere first. Right now, that declaration is made in a module so that the form is global (I need to call a sub on this form from another form). What would you suggest I do?

Is there a specific reason for developing in such an outdated version of VB?
If you could update to more recent VB version, you could make use of the My.Application.OpenForms collection. I believe the My namespace became available in VB2005.

The version nis what I have, I'm NOT buying another version to do something so simple. I'm sorry I asked for help.

I'm NOT buying another version to do something so simple

Have you never heard of the free express editions? Granted you do not get all the bells and whistles of the full VS suite, but they do offer a full implimentation of the language.

Visual Basic 2005 Express Edition (445,282 KB)
* IMG File (http://go.microsoft.com/fwlink/?linkid=54764)
* ISO File (http://go.microsoft.com/fwlink/?linkid=57033)

Visual Studio 2008 Express Editions
http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express

Visual Basic 2010 Express
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

Ok, here's the deal... When I attempt to use the form name, I do NOT get the option to open my form. I have to declare it somewhere first. Right now, that declaration is made in a module so that the form is global (I need to call a sub on this form from another form). What would you suggest I do?

Perhaps, it it not really an issue of whether the form is currently visible, but rather one of how to reference your instance of that form?

Public Class Form1
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      ModTest.frmTest.TheOneIWant()
   End Sub
End Class

Public Module ModTest
   Public frmTest As New Testform
   Public Class Testform
      Inherits Form
      Public Sub TheOneIWant()
         MsgBox("yep, I'm here")
      End Sub
   End Class
End Module
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.