[导入]ASP常用函数:DelArray2()

<%
'功能:删除二维数组中的iColumn列上值为sValue的行,当iColumn为-1时删除第sValue行
'来源:http://jorkin.reallydo.com/article.asp?id=483

Function DelArray2(aArray, iColumn, sValue, bCompare)
    
If Not IsArray(aArray) Then Exit Function
    Dim
i, j, k, iUBound1, iUBound2
    iUBound1 = UBound(aArray)
    
iUBound2 = UBound(aArray, 2)
    
k = -1
    
Dim aTmpArray()
    
ReDim aTmpArray(iUBound1, k)
    
If iColumn < 0 Or iColumn > iUBound1 Then
        For
i = 0 To iUBound2
            If StrComp(i, sValue, bCompare)<>0 Then
                
k = k + 1
                
ReDim Preserve aTmpArray(iUBound1, k)
                
For j = 0 To iUBound1
                    aTmpArray(j, k) = aArray(j, i)
                
Next
            End If
        Next
    Else
        For
i = 0 To iUBound2
            If StrComp(aArray(iColumn, i), sValue, bCompare)<>0 Then
                
k = k + 1
                
ReDim Preserve aTmpArray(iUBound1, k)
                
For j = 0 To iUBound1
                    aTmpArray(j, k) = aArray(j, i)
                
Next
            End If
        Next
    End If
    
DelArray2 = aTmpArray
End Function
%>


文章来源:http://Jorkin.Reallydo.Com/default.asp?id=483
posted @ 2008-03-12 13:22  pboy2925  阅读(120)  评论(0编辑  收藏  举报