Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Multiple Instances of an application


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
MOvais_Khan
Asked:
MOvais_Khan
1 Solution
 
JigglyDCommented:
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
 
purquizCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now