Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


finding a running instance of a form in vb.net

Posted on 2004-10-26
Medium Priority
Last Modified: 2012-05-05
  I want to know how i can find an running instance of a form so that i can restrict the user to reopen the same form again.
 Say as a address book is open using this code lines.......

  Dim addbook_new As New frmAddressBook()

if the user again clicks address book link , and if the address book already open , then restrict the user to reopen it. all i want is to find an running instance of an form...

I don't want to use a variable for decision.....

Please reply.....


Question by:manish_prajapati
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 12409104
Can't you just use the visible property of the form to identify if it's visible?

If frmAddBook.visble then exit sub ...
LVL 76

Expert Comment

ID: 12409139
There is a VB.Net area. The answers you get here are likely to be biased towards non-.Net visual basic.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12409724
Hi, There is problem in it.. I am explaining you..

Suppose i take a global declaration as
   dim frmaddbook as new frmaddressbook()

and on clicking address book Icon , i show the form by

when user again clicks the ICON ,I check if frmaddbook.visible=ture and if ture then EXIT SUB.
if user closes the address book form and after then clicks the address book ICON...it gives a fault that .. frmaddbook instance is diaposed and it couldn't be shown bt .show

I need to find the instance of frmaddbook so that i can check the status whether it is open ,closed....\

LVL 86

Accepted Solution

Mike Tomlinson earned 400 total points
ID: 12410218
You can do it using a technique similar to this:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private WithEvents frmAB As frmAddBook

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If frmAB Is Nothing Then
            frmAB = New frmAddBook
        ElseIf frmAB.WindowState = FormWindowState.Minimized Then
            frmAB.WindowState = FormWindowState.Normal
        End If
    End Sub

    Private Sub frmAB_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles frmAB.Closed
        frmAB = Nothing
    End Sub

End Class


Author Comment

ID: 12418799
Thanks, It is working


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question