Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba VB6上函数的返回值_Vba_Vb6 - Fatal编程技术网

Vba VB6上函数的返回值

Vba VB6上函数的返回值,vba,vb6,Vba,Vb6,我有一个关于在VB6.0中返回函数值的问题。下面是我的代码 Public Function tracePackageError(oPackage As DTS.Package) As String Dim ErrorCode As Long Dim ErrorSource As String Dim ErrorDescription As String Dim ErrorHelpFile As String Dim ErrorHelpContext As Long Dim ErrorIDofIn

我有一个关于在VB6.0中返回函数值的问题。下面是我的代码

Public Function tracePackageError(oPackage As DTS.Package) As String
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

    For i = 1 To oPackage.Steps.Count
            If oPackage.Steps(i).ExecutionResult = DTSStepExecResult_Failure Then
               oPackage.Steps(i).GetExecutionErrorInfo ErrorCode, ErrorSource, ErrorDescription, _
               ErrorHelpFile, ErrorHelpContext, ErrorIDofInterfaceWithError                                                                                           
            End If
    Next i

End Function

如何返回函数的值?请帮忙:(

我想这对你会有用的

Public Function tracePackageError(oPackage As DTS.Package) As String
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

    For i = 1 To oPackage.Steps.Count
            If oPackage.Steps(i).ExecutionResult = DTSStepExecResult_Failure Then
               oPackage.Steps(i).GetExecutionErrorInfo ErrorCode, ErrorSource, ErrorDescription, _
               ErrorHelpFile, ErrorHelpContext, ErrorIDofInterfaceWithError 
               tracePackageError = ErrorDescription                                                                      
            End If
    Next i

End Function

试试看,让我知道

你所需要的只是在你的函数中的某个地方添加
tracePackageError=[返回值]
,可能在
下一步之后我
谢谢你的回复KazimierzJawor先生…我还是个编程新手..我将在[返回值]中输入什么值,正如你所说的(啊,好的,我明白了,谢谢KazimierzJawor先生:)仍然没有工作对不起:(阅读文档。谢谢Indago先生..当我尝试测试我的函数时,我遇到了一个错误:“对象变量或块变量未设置”。这是我的代码私有子命令1_Click(),如果tracePackageError”“那么MsgBox”错误发生:&vbCrLf&tracePackageError End If End SubIm在此处获取i=1到oPackage.Steps.Count的错误(&vbCrLf)