我的这个程序为什么会出错?
程序如下:
Private Sub Form_Unload(Cancel As Integer)
Dim hThread, lpThreadID As Long
Dim a As String
g_bDone = False
g_strTitle = "Close "
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf
HookInputBoxThread, ByVal 0&, 0, lpThreadID)
a = Trim(InputBox( "Please input the correct Password! " + vbCrLf + "Operator can not close it! ", g_strTitle))
If a <> " " Then
If a = "123 " Then
Call ReleaseHook
gadoCn.Close
Unload Me
Else
MsgBox "The Password isn 't correct! ", 0 + 16, "Warning "
Cancel = 1
End If
Else
Cancel = 1
End If
End Sub
问题:当我在关闭程序点击窗口右上角叉时,程序可以自动按照程序关闭,但是当把以上程序放在窗体的一个关闭按钮里面时,当点击关闭(EXIT)按钮时,程序报错后,点击确定程序自动关闭怎么回事?
出错现象:弹出一个msgbox对话框
Run-time error "3704 ":
Operation is not allowed when the object is closed!
[解决办法]
gadoCn.Close哪来的? 什么时候定义的
if gadocn.state=2 then gadocn.close
[解决办法]
你试试看
private sub mnuExit_Click()
unload me
end sub
[解决办法]
你把代码贴全,估计是你程序有逻辑错误
[解决办法]
这种错误通过单步运行很容易调试吧