VB怎样判断、防止程序重复执行

前端之家收集整理的这篇文章主要介绍了VB怎样判断、防止程序重复执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Private Sub Form_load() '判断程序是否已经运行 If App.PrevInstance Then MsgBox "本程序已经运行!",vbInformation Or vbOKOnly,"提示信息" 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 Sub Private Sub Form_Load() Call CheckExist(Me) End Sub

原文链接:https://www.f2er.com/vb/262361.html

猜你在找的VB相关文章