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
相关文档:
参照案例教程建立的数据库管理系统在甚多方面都存在问题。可能是新手,不管是对于大一就学过的VB编程还是这个学期刚接触的SQL,很多小问题常常出现在调试过程中。想请熟悉使用这两个平台的高手帮忙指点一下。
1.如何解决DataGrid中多个column和SQL中多个表的绑定?目的 ......
'代码:
Option Explicit
'======================用于查找进程和终止进程的API函数常数定义================ =====
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessF ......
VB6
在程序运行时用如下语句:
if app.PrevInstance=true then
end
end if
VB 2005:
1. 在VB2005中,打开"属性"页,启用"应用程序“框架, 选中"
单实例应用程序"前面复选框,就行了。
......
Option Explicit
Dim potflag As Integer '标识是否用小数点
Dim numcol As Integer ' 点击运算符的个数
Dim LastInput ' 指示上一次操作的内容
Dim colflag ......
Option Explicit
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
Private Type NCB
ncb_command As Byte
ncb_retcode As Byte
ncb_lsn As Byte
ncb_num As Byte ......