本文介绍了比较两个数组的价值观 - 传统的ASP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何比较两个数组的值来检查,如果1阵列没有另一个数组例如一个元素 -

 数组1(0)= 85
ARRAY1(1)= 459
ARRAY1(2)= 90数组2(0)= 459
数组2(1)= 90

我要退回没有第二个数组中的present值?我试着用双for循环,但没有制定出适合我。


解决方案

 暗淡数组1(3)
暗淡的数组2(2)ARRAY1(0)= 85
ARRAY1(1)= 459
ARRAY1(2)= 90数组2(0)= 459
数组2(1)= 90昏暗我'作为整数
昏暗的J'作为整数
昏暗isFound作为布尔对于i = 0到UBound函数(数组1) - 1
    isFound =假
    对于j = 0要UBound函数(数组2) - 1
        如果数组1(I)=数组2(J)然后
            isFound = TRUE
        万一
    下一步'J
    如果不isFound然后
        回复于ARRAY1(ⅰ)及找不到< BR />中
    万一
下一步'我

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 09:54