A Singleton Function for VB
Category:
MiscellaneousType:
SnippetsDifficulty:
BeginningAuthor:
AnonymousVersion Compatibility: Visual Basic 6
More information:
This function, similar to a singleton in Java, includes comments to help understand it's simple use. Just call the procedure with or without the optional boolean parameter to show or not show a message box. If a previous instance exists, the sub activates that instance and cancels the new one.
I have not tested this in VB5 but it work son VB6 fine.
I suggest you include the call to the sub in the sub main.
Call CheckPreviousInstance
OR
Call CheckPreviousInstance True|False
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: