我有一个数组
arrIP={"10","144","26,"0"}
and another array
arrItc={"10","126","0","0"}
我想检查前三个值的相等性,如果所有三个值都相等,则返回一个布尔值
答案 0 :(得分:1)
使用布尔表达式或循环:
Option Explicit
Dim aTests : aTests = Array( _
Split("10 144 26 0") _
, Split("10 144 26 0") _
, Split("10 144 26 1") _
, Split("10 144 27 0") _
, Split("10 145 26 0") _
, Split("11 144 26 0") _
)
Dim nTest
For nTest = 1 To UBound(aTests)
WScript.Echo Join(aTests(0)), "?", Join(aTests(nTest)), CStr(cmp3(aTests(0), aTests(nTest)))
Next
Function cmp3(aL, aR)
cmp3 = aL(0) = aR(0) And aL(1) = aR(1) And aL(2) = aR(2)
End Function
Function cmp3(aL, aR)
cmp3 = False
Dim i
For i = 0 To 2
If aL(i) <> aR(i) Then Exit Function
Next
cmp3 = True
End Function
输出:
10 144 26 0 ? 10 144 26 0 Wahr
10 144 26 0 ? 10 144 26 1 Wahr
10 144 26 0 ? 10 144 27 0 Falsch
10 144 26 0 ? 10 145 26 0 Falsch
10 144 26 0 ? 11 144 26 0 Falsch
答案 1 :(得分:0)
还有一个要测试的想法。
a1 = Array("10", "144", "26", "0")
a2 = Array("10", "126", "0", "0")
a3 = Array("10", "144", "26", "1")
a1(UBound(a1)) = ""
a2(UBound(a2)) = ""
a3(UBound(a3)) = ""
WScript.Echo "a1=a2 ? " & (Join(a1) = Join(a2))
WScript.Echo "a2=a3 ? " & (Join(a2) = Join(a3))
WScript.Echo "a1=a3 ? " & (Join(a1) = Join(a3))
'Result:
a1=a2 ? False
a2=a3 ? False
a1=a3 ? True