If App.PrevInstance Then MsgBox "程序已经运行!", vbInformation End End If
Private Sub Form_Load() If App.PrevInstance = True Then MsgBox "系统已启动,请按ALT+TAB键查找" Unload Me Exit Sub End If
End Sub
Option Explicit Public Sub CheckExist(fm As Form) Dim title As String If App.PrevInstance Then title = App.title Call MsgBox("这程序已执行", vbCritical) App.title = "" '如此才不会Avtivate到自己 fm.Caption = "" AppActivate title 'activate 先前就已行的程序 End End If End SubPrivate Sub Form_Load() Call CheckExist(Me) End Sub
如果不考虑不同路径重合名等可以这样 If App.PrevInstance Then msgbox "程序已在运行" else end if
MsgBox "程序已经运行!", vbInformation
End
End If
If App.PrevInstance = True Then
MsgBox "系统已启动,请按ALT+TAB键查找"
Unload Me
Exit Sub
End If
End Sub
Public Sub CheckExist(fm As Form)
Dim title As String
If App.PrevInstance Then
title = App.title
Call MsgBox("这程序已执行", vbCritical)
App.title = "" '如此才不会Avtivate到自己
fm.Caption = ""
AppActivate title 'activate 先前就已行的程序
End
End If
End SubPrivate Sub Form_Load()
Call CheckExist(Me)
End Sub
If App.PrevInstance Then
msgbox "程序已在运行"
else
end if