VB6上的函数返回值

时间:2016-12-29 06:36:58

标签: 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 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

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

1 个答案:

答案 0 :(得分:1)

我认为这对你有用......

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

尝试一下,让我知道