我在窗体onload的时候要进行一些必要的配置文件检查,如果没有配置就不能打开该窗体,例如
Dim dirtmp As String
dirtmp = Dir(sPath & "\config.ini")
If scftmp = "" Then
StrFax = ""
MsgBox "配置文件丢失
Unload Me
End If
报错说 object was unload 怎么办啊?
由于Active事件另要处理其他事情,不能写在那里面,否则问题就好解决了,现在要在onload里面怎么解决这个问题呢??
Dim dirtmp As String
dirtmp = Dir(sPath & "\config.ini")
If scftmp = "" Then
StrFax = ""
MsgBox "配置文件丢失
Unload Me
End If
报错说 object was unload 怎么办啊?
由于Active事件另要处理其他事情,不能写在那里面,否则问题就好解决了,现在要在onload里面怎么解决这个问题呢??
object was unload 在哪里出来的?
免费的学习交流网站,欢迎大家访问!
http://www.j2soft.cn/
http://j2soft.008.net/
Private Sub Form_Load()
Dim dirtmp As String
dirtmp = Dir(sPath & "\config.ini")
If scftmp = "" Then
StrFax = ""
MsgBox "配置文件丢失
Unload Me
MsgBox "sdf"
End If
End Sub
frm_Detail.Show这个窗体的onload事件里面写
Private Sub Form_Load()
Dim dirtmp As String
dirtmp = Dir(sPath & "\config.ini")
If scftmp = "" Then
StrFax = ""
MsgBox "配置文件丢失
Unload Me
MsgBox "sdf" //这个也可以显示
End If
End Sub
单步调试到 End Sub 就出错了, object was unloaded
----------------
主窗体:Form_Load
子窗体:Form_Load
----------------
所以你无法将子窗体的 Form_Load 中断掉。应该先启动主窗体,在主窗体的 Form_Load 进行检查,检查成功再显示子窗体。
Private Sub Form_Activate()
或者
Private Sub Form_GotFocus()
写到这里面应该是可以的
用 unload 窗体名 试试看
我晕,你不会定义一个blnChkLoad的变量啊
Form_Load
BLNCHKLOAD=TRUE
IF THEN
BLNCHKLOAD=FALSE
END IF
END SUB
Form_Activate
IF BLNCHKLOAD=FALSE THEN UNLOAD ME
。
。
。
END SUB