高分求答案了,vb 程序在调试状态上可以正常执行,但是在运行状态上却不能正常执行,这是为什么
高分求答案了,vb 程序在调试状态下可以正常执行,但是在运行状态下却不能正常执行,这是为什么?
1.不是路径问题
2.我做的东东主要是一个大的软件中的一个插件。
2.代码如下:
Public Function GetAutoOrderGtCode() As String
'On Error GoTo error1
'On Error Resume Next
GetAutoOrderGtCode = ""
Dim objGtCode As PIMSGTCodeExecutor
Set objGtCode = m_Session.GetGTCodeIntergration("PIMSCodeIntegration.PIMSGTCodeExecutor")
If Not objGtCode Is Nothing Then
Dim strCode As String
If objGtCode.Initialize(m_Session) <> 0 Then
If IsAutoOrderCode = True Then
objGtCode.AutoOrderCode m_ObjClassID, strCode
End If
Else
MsgBox "无法获取企业编码,请确认编码系统是否正确安装", vbInformation, gstrTitle
End If
If Not strCode = "" Then
GetAutoOrderGtCode = strCode
StrTmpCode = strCode
ISUseGTCode = True
End If
End If
' Exit Function
'error1:
' MsgBox Err.Description, vbInformation, gstrTitle
End Function
问题主要出在
If objGtCode.Initialize(m_Session) <> 0 Then
上,在调试状态下,可以走到
MsgBox "无法获取企业编码,请确认编码系统是否正确安装", vbInformation, gstrTitle
这一步,但是在运行状态下发现,他直接跳出了GetAutoOrderGtCode方法,请问高手这是为什么?
------解决方案--------------------
可能是在msgbox 之前的代码里出现了错误,或者在funtion之外就出现错误了
------解决方案--------------------
搞了半天就是 F8单步执行能走到If objGtCode.Initialize(m_Session) <> 0 Then
没断点 就提示GetAutoOrderGtCode方法内有错误
。。。。。
------解决方案--------------------
调试状态能走到MSGBOX,说明没有出错,是通过判断objGtCode.Initialize(m_Session)为零之后,按分支走到的MSGBOX.
编译后,直接跳出,说明产生了错误或根本没执行到这个分支,从而被上层的错误陷阱捕捉到了或,直接由上面的IF IS NOTHING跳出.
我认为你应该检查编译后运行环境,与IDE中执行的环境有什么区别.
另,"根本没执行到这个分支"的情况,看你的部分代码:
1.不是路径问题
2.我做的东东主要是一个大的软件中的一个插件。
2.代码如下:
Public Function GetAutoOrderGtCode() As String
'On Error GoTo error1
'On Error Resume Next
GetAutoOrderGtCode = ""
Dim objGtCode As PIMSGTCodeExecutor
Set objGtCode = m_Session.GetGTCodeIntergration("PIMSCodeIntegration.PIMSGTCodeExecutor")
If Not objGtCode Is Nothing Then
Dim strCode As String
If objGtCode.Initialize(m_Session) <> 0 Then
If IsAutoOrderCode = True Then
objGtCode.AutoOrderCode m_ObjClassID, strCode
End If
Else
MsgBox "无法获取企业编码,请确认编码系统是否正确安装", vbInformation, gstrTitle
End If
If Not strCode = "" Then
GetAutoOrderGtCode = strCode
StrTmpCode = strCode
ISUseGTCode = True
End If
End If
' Exit Function
'error1:
' MsgBox Err.Description, vbInformation, gstrTitle
End Function
问题主要出在
If objGtCode.Initialize(m_Session) <> 0 Then
上,在调试状态下,可以走到
MsgBox "无法获取企业编码,请确认编码系统是否正确安装", vbInformation, gstrTitle
这一步,但是在运行状态下发现,他直接跳出了GetAutoOrderGtCode方法,请问高手这是为什么?
------解决方案--------------------
可能是在msgbox 之前的代码里出现了错误,或者在funtion之外就出现错误了
------解决方案--------------------
搞了半天就是 F8单步执行能走到If objGtCode.Initialize(m_Session) <> 0 Then
没断点 就提示GetAutoOrderGtCode方法内有错误
。。。。。
------解决方案--------------------
调试状态能走到MSGBOX,说明没有出错,是通过判断objGtCode.Initialize(m_Session)为零之后,按分支走到的MSGBOX.
编译后,直接跳出,说明产生了错误或根本没执行到这个分支,从而被上层的错误陷阱捕捉到了或,直接由上面的IF IS NOTHING跳出.
我认为你应该检查编译后运行环境,与IDE中执行的环境有什么区别.
另,"根本没执行到这个分支"的情况,看你的部分代码:
Dim objGtCode As PIMSGTCodeExecutor
Set objGtCode = m_Session.GetGTCodeIntergration("PIMSCodeIntegration.PIMSGTCodeExecutor")
If Not objGtCode Is Nothing Then