?
Solved

Multiple Instances of an application

Posted on 2005-03-20
6
Medium Priority
?
217 Views
Last Modified: 2010-04-17

Dear Experts,

How can we prevent a VB program from running multiple instance of it. As some users intentionally try to open multiple instance the program.

Rgds/Shihab
0
Comment
Question by:MOvais_Khan
[X]
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
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 13589230
0
 
LVL 3

Expert Comment

by:JigglyD
ID: 13589452
Try This...

Sub Main()
      If App.PrevInstance Then
         MsgBox "An instance of this program is already running...", vbInformation, ""
         Unload Me
      Else
         frmMain.Show  '*** Assuming that frmMain is your current Startup form
      End If
End Sub

Jiggle On ! ! !
0
 
LVL 2

Expert Comment

by:purquiz
ID: 13592333
GIVE ME NO POINTS FOR THIS------------------------

because JigglyD wrote the same code (almost)

If u want just to unload the new instance, with no messages, etc, just write:

If app.previnstance then end

inside the Sub Main()
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

764 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