2017-07-25 78 views
-1

我有我的下面的代碼和外部數組沒有比較每個值與內部數組。外部數組與內部的一個值進行比較,並移至其中的下一個值。VB腳本。需要在UFT工具的代碼下運行

testdata = {25,27,81,104,33,34,56,78,99,84} 
testdata1 = {81,104} 

For i = 0 To UBound(testdata) - 1 

For j = 0 To UBound(testdata1) - 1 
    If testdata(i) = testdata1(j) Then 
     isFound = True 
     Call DB_Connectionwisdataflagupdation(sQuery,Para2,Para3,Para4,sValue) 
    'c=c+1 
    Exit for 
    End If 

     'isFound = True 


    isFound = False 
Next 
Next 

請幫我解決這個問題。

+1

你爲什麼從UBOUND(ARR)減去1?只需運行循環到ubound(arr),你應該沒問題。 – Gurman

回答

2

我做了幾個小的改動你的代碼,主要是調整對指數的for循環:

Dim i As Integer 
    Dim j As Integer 
    Dim isFound As Boolean 

    For i = LBound(testdata) To UBound(testdata) 
     For j = LBound(testdata1) To UBound(testdata1) 
      If testdata(i) = testdata1(j) Then 
      isFound = True 
      'Call DB_Connectionwisdataflagupdation(sQuery, Para2, Para3, Para4, sValue) 
      MsgBox testdata(i) 
      Exit For 
      End If 

      isFound = False 
     Next 
    Next 
+0

非常感謝..它爲我工作... –

+0

接受答案然後,請 – adrianmcmenamin