VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Instance Checker

by Tyler Badger (1 Submission)
Category: Coding Standards
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

This simple few lines of code will give the user and error message if they are already running your program. Doesn't apply if you are in the ide!

Rate Instance Checker

Private Sub Form_Load() ' the form1 loading sub
If App.PrevInstance Then ' check if running
  MsgBox "Error:" & vbCrLf & "Please switch to your already running app." ' error message
 Dim frm As Form ' set frm variable as a form
 For Each frm In Forms ' get all forms
  Unload frm ' unload the form
  Set frm = Nothing ' set frm variable as nothing
 Next frm ' go to the for each frm again
 End If ' end the if statement
End Sub ' end the form load

Download this snippet    Add to My Saved Code

Instance Checker Comments

No comments have been posted about Instance Checker. Why not be the first to post a comment about Instance Checker.

Post your comment

Subject:
Message:
0/1000 characters