日期:2014-05-17  浏览次数:20805 次

对应删除数组里数据的问题(有点难度)
现有三个数组
A
307,   306,   305,   304,   303

B

1,   5,   1,   5,   6

C

0,   1,   0,   1,   8

这三个数组长度是一致的,其中A数组数值不会重复

请问,如果删除   A   数组中的某一个数据,能把   B、C相应位置的数值删除呢?!

比如,,在删除   A   数组中的   元素   304   ,能同时把   B中的   5   和C   中的1
相对应的数值删除

呵呵,应该有点难度,,请高手帮忙


------解决方案--------------------
利用recordset操作:
<%
A = Array(307, 306, 305, 304, 303)
B = Array(1, 5, 1, 5, 6)
C = Array(0, 1, 0, 1, 8)

Set rs = CreateObject( "ADODB.RecordSet ")
rs.cursorLocation = 3
rs.Fields.Append "A ", 3
rs.Fields.Append "C ", 3
rs.Fields.Append "B ", 3
rs.open
Dim aFlds(2), aVals(2)
aFlds(0) = "A "
aFlds(1) = "B "
aFlds(2) = "C "

For i=0 To UBound(A)
aVals(0) = A(i)
aVals(1) = B(i)
aVals(2) = C(i)
rs.AddNew aFlds, aVals
Next

rs.moveFirst

rs.Find "A=304 "
rs.Delete

Erase A
Erase B
Erase C

ReDim A(rs.RecordCount-1), B(rs.RecordCount-1), C(rs.RecordCount-1)

i=0
rs.moveFirst
Do While Not rs.eof
A(i) = rs( "A ")
B(i) = rs( "B ")
C(i) = rs( "C ")
i = i+1
rs.moveNext
Loop

Response.Write i
Set rs = Nothing

For i=0 To UBound(A)
Response.Write A(i) & ", "
Response.Write B(i) & ", "
Response.Write C(i) & ", "
Response.Write " <br> "
Next
%>