Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAllow only one instance of a program
Keywordsinstance, program
CategoriesTips and Tricks, Windows
 
Thanks to C. K. Lam.

Use App.PrevInstance to see if a previous instance is already running.

 
Private Sub Form_Load()
    ' See if there is already and instance.
    If App.PrevInstance Then
        ' Activate the previous instance
        AppActivate App.Title

        ' Send a key (here SHIFT-key) to set the
        ' form from the previous instance to the
        ' top of the screen.
        SendKeys "+", True

        ' Terminate the new instance
        Unload Me
    End If
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated