本文介绍了比较两个数组的值——经典的asp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如何比较两个数组的值以检查一个数组是否没有另一个数组的元素 -
How can I Compare values of two arrays to check if 1 array does not have an element of another array for example -
array1(0) = 85
array1(1) = 459
array1(2) = 90
array2(0) = 459
array2(1) = 90
我想返回第二个数组中不存在的值?我尝试使用双 for 循环,但对我来说效果不佳.
I want to return the values that are not present in the second array? I tried with double for loops but didn't work out to well for me.
推荐答案
Dim array1(3)
Dim array2(2)
array1(0) = 85
array1(1) = 459
array1(2) = 90
array2(0) = 459
array2(1) = 90
Dim i 'As Integer
Dim j 'As Integer
Dim isFound 'As Boolean
For i = 0 To UBound(array1) - 1
isFound = False
For j = 0 To UBound(array2) - 1
If array1(i) = array2(j) Then
isFound = True
End If
Next 'j
If Not isFound Then
Response.Write array1(i) & " not found<br />"
End If
Next 'i
这篇关于比较两个数组的值——经典的asp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!