在你的ENDSYSTEM过程中,这样处理一下: .... doevents '让系统先做完现在的事情 if rs.status=1 then '关闭记录集 rs.close end if set rs=nothing if cn.status=1 then '关闭数据库连接 cn.close end if set cn=nothing doevents unload me .....
Dim i As Integer Dim frm As Form '// Timer end If frmBill.tmrMark.Enabled Then frmBill.tmrMark.Enabled = False End If '// TB End If frmBill.TB.Enabled Then frmBill.TB.Enabled = False End If
If Not pHead Is Nothing Then Set pHead = Nothing End If If Not pv Is Nothing Then Set pv = Nothing End If '// End system,Give UOL SERVER to send QUIT command. If frmBill.WS_UOLS.State = sckConnected Then frmBill.WS_UOLS.SendData m_CMDQUIT Wait 1 End If '// Destruct Winsock For i = 0 To gSockets If frmBill.WS_GW(i).State <> sckClosed Then frmBill.WS_GW(i).Close End If Next i
If frmBill.WS_UOLS.State <> sckClosed Then frmBill.WS_UOLS.Close End If
For Each frm In Forms Unload frm Next
If Not gRs Is Nothing Then gRs.Close End If Set gRs = Nothing
If Not gDatabase Is Nothing Then gDatabase.Close End If
Set gDatabase = Nothing
特别是关闭快速时,总是跳到窗体级过程中的记录集检索那里,FORM中:Private Sub RefreshGridMark() Dim sql As String Dim strClip As String Dim Cols As Integer Dim Rows As Integer
Dim rs As New ADODB.Recordset
strClip = Empty
Rows = 0 Cols = 2
sql = "select * from Mark"
Set gRs = New ADODB.Recordset Set gRs = gDatabase.Execute(sql) With gRs Do While Not .EOF strClip = strClip & .Fields("cIPCardNo") & vbTab & .Fields("mMark") & vbCr Rows = Rows + 1 .MoveNext Loop .Close End With Set gRs = Nothing
....
doevents '让系统先做完现在的事情
if rs.status=1 then '关闭记录集
rs.close
end if
set rs=nothing
if cn.status=1 then '关闭数据库连接
cn.close
end if
set cn=nothing
doevents
unload me
.....
Dim frm As Form '// Timer end
If frmBill.tmrMark.Enabled Then
frmBill.tmrMark.Enabled = False
End If
'// TB End
If frmBill.TB.Enabled Then
frmBill.TB.Enabled = False
End If
If Not pHead Is Nothing Then
Set pHead = Nothing
End If
If Not pv Is Nothing Then
Set pv = Nothing
End If '// End system,Give UOL SERVER to send QUIT command.
If frmBill.WS_UOLS.State = sckConnected Then
frmBill.WS_UOLS.SendData m_CMDQUIT
Wait 1
End If '// Destruct Winsock
For i = 0 To gSockets
If frmBill.WS_GW(i).State <> sckClosed Then
frmBill.WS_GW(i).Close
End If
Next i
If frmBill.WS_UOLS.State <> sckClosed Then
frmBill.WS_UOLS.Close
End If
For Each frm In Forms
Unload frm
Next
If Not gRs Is Nothing Then
gRs.Close
End If
Set gRs = Nothing
If Not gDatabase Is Nothing Then
gDatabase.Close
End If
Set gDatabase = Nothing
Dim sql As String
Dim strClip As String
Dim Cols As Integer
Dim Rows As Integer
Dim rs As New ADODB.Recordset
strClip = Empty
Rows = 0
Cols = 2
sql = "select * from Mark"
Set gRs = New ADODB.Recordset
Set gRs = gDatabase.Execute(sql)
With gRs
Do While Not .EOF
strClip = strClip & .Fields("cIPCardNo") & vbTab & .Fields("mMark") & vbCr Rows = Rows + 1
.MoveNext
Loop
.Close
End With
Set gRs = Nothing
ClipToGrid msfIpCard, strClip, Rows + msfIpCard.FixedRows, Cols
cmdEdit(m_CMDDEL).Enabled = (msfIpCard.FixedRows <> msfIpCard.Rows)
cmdEdit(m_CMDMARK).Enabled = (msfIpCard.FixedRows <> msfIpCard.Rows)
End Sub
Public Function Wait(i As Integer)
Dim PauseTime, Start
PauseTime = i ' 设置暂停时间。
Start = Timer ' 设置开始暂停的时刻。
Do While Timer < Start + PauseTime
DoEvents ' 将控制让给其他程序。
Loop
End Function
If Not gDatabase Is Nothing Then
gDatabase.Close
End If