Crystal Reports Designer  

結束 For/Next 迴圈 (Basic 語法)

Exit For 陳述式可用來結束 For/Next 迴圈。以下的範例會搜尋全域陣列名稱中是否有 Fred 這個名字。假如找到這個名字,就會傳回這個名字在陣列中的索引。否則的話,就傳回 –1。例如,假如名稱陣列為:

Array ("Frank", "Helen", "Fred", "Linda")

則公式會傳回 3。

Global names () As String
'The names array has been initialized and filled
'in other formulas
Dim i
formula = -1
'The UBound function returns the size of its array
'argument
For i = 1 to UBound (names)
   If names (i) = "Fred" Then
      formula = i
      Exit For
   End If
Next I

請參閱

For/Next 迴圈