递归函数出错
我在网上找了一个函数,但调用时提示定义出错
该怎么调用?请指点
程序代码:
Function Traverse(ByVal PN As String, ByVal MakeBuy As String, ByVal Qty As Double, ByVal arr_Comp As Variant, ByVal BOM As Variant) j = 0 For j = LBound(BOM) To UBound(BOM) 'Step through BOM If BOM(j, 1) = PN Then 'Parent found in array, is an assembly ReDim Preserve arr_Comp(0 To 3, 0 To UBound(arr_Comp, 2) + 1) arr_Comp(0, UBound(arr_Comp, 2)) = BOM(j, 2) 'child arr_Comp(1, UBound(arr_Comp, 2)) = UCase(BOM(j, 7)) 'make/buy arr_Comp(2, UBound(arr_Comp, 2)) = BOM(j, 3) * Qty 'exploded qty arr_Comp(3, UBound(arr_Comp, 2)) = BOM(j, 1) 'Parent Debug.Print BOM(j, 2) & " (" & BOM(j, 7) & ") added to arr_Comp, BOM row " & j PN = BOM(j, 2) MakeBuy = UCase(BOM(j, 7)) Qty = BOM(j, 3) * Qty If MakeBuy = "E" Then 'Keep progressing through BOM Call Traverse(PN, MakeBuy, Qty, arr_Comp(), BOM()) End If End If Next j End Function