How to make the message in my code to appear?

  • Thread starter Thread starter Max45-1
  • Start date Start date
M

Max45-1

Guest
Hi all,

I have this code and it works fine but the message doesn't appear when I try to run another instance of my application

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If PrevInstance() Then
MessageBox.Show("The App Is Already Running")
Me.Close()
Exit Sub
End If
End Sub

Function PrevInstance() As Boolean
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
Else
Return False
End If
End Function
End Class

Continue reading...
 
Back
Top