私は配列を持っています
arrIP={"10","144","26,"0"}
and another array
arrItc={"10","126","0","0"}
最初の 3 つの値が等しいことを確認し、3 つすべてが等しい場合はブール値を返したい
私は配列を持っています
arrIP={"10","144","26,"0"}
and another array
arrItc={"10","126","0","0"}
最初の 3 つの値が等しいことを確認し、3 つすべてが等しい場合はブール値を返したい
ブール式またはループを使用します。
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 つのアイデア。
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