Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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
Debugging Excel VBA返回行为异常,跳回_Debugging_Vba_Excel - Fatal编程技术网

Debugging Excel VBA返回行为异常,跳回

Debugging Excel VBA返回行为异常,跳回,debugging,vba,excel,Debugging,Vba,Excel,在完成if语句后,这种行为真的很奇怪 我在上面运行了调试器,下面是它的跳转方式: Private Function GetLastSameRow(ByVal row, initialValue) As Integer . . . If (nextCell.Value = initialValue) Then GetLastSameRow = GetLastSameRow(row + 1, initialValue) End If MsgBox ("

在完成if语句后,这种行为真的很奇怪

我在上面运行了调试器,下面是它的跳转方式:

Private Function GetLastSameRow(ByVal row, initialValue) As Integer
   .
   .
   .
   If (nextCell.Value = initialValue) Then
      GetLastSameRow = GetLastSameRow(row + 1, initialValue)
   End If
   MsgBox ("returning  : " & row)
   GetLastSameRow = row
End Function

因此,它基本上希望返回
correct
值,但如果
返回
End,则会立即返回
correct-1
值。

您编写了一个递归函数!如果使用调用堆栈,您将看到调试器将转到函数的另一个实例。问题在于:

GetLastSameRow=GetLastSameRow(行+1,初始值)


调用函数的另一个实例

您已经编写了一个递归函数!如果使用调用堆栈,您将看到调试器将转到函数的另一个实例。问题在于:

GetLastSameRow=GetLastSameRow(行+1,初始值)


调用函数的另一个实例

它是递归的这一事实不是问题?它是递归的这一事实不是问题?我一看到它就不相信自己知道这是正确的答案。我一看到它就不相信自己知道这是正确的答案
1. End If                            '
2. MsgBox ("returning  : " & row)    ' row value is 3
3. GetLastSameRow = row              '
4. MsgBox ("returning  : " & row)    ' row value is 2 ????????
5. GetLastSameRow = row              '