VB脚本。需要在UFT工具的代码下运行
问题描述:
我有我的下面的代码和外部数组没有比较每个值与内部数组。外部数组与内部的一个值进行比较,并移至其中的下一个值。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
请帮我解决这个问题。
答
我做了几个小的改动你的代码,主要是调整对指数的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
你为什么从UBOUND(ARR)减去1?只需运行循环到ubound(arr),你应该没问题。 – Gurman