--> (Word) | --> (PDF) | --> (Epub) | |
This article has been published [fromdate] |
You can read the PrevInstance property of the App object, if the value of this is True then another instance of the application is already running. If your program starts with Sub Main, you can use this code to exit the program if another copy is already running:
VB Code:
'in sub main...
If App.PrevInstance = True Then
MsgBox "Already running...."
Exit Sub
End If
For forms you need an extra piece of code to also close the form, the following code should be placed in Form_load:
VB Code:
'in form_load...
If App.PrevInstance = True Then
MsgBox "Already running...."
Unload Me
Exit Sub
End If
SOURCE | LINK (Vbforums.com)
| LANGUAGE | ENGLISH |