Rob Meade wrote:
"Bob Barrows [MVP]" wrote ...
nope
yup
LOL..
Thanks Bob - I've been doing this for 2 hours now and its driving me
bl**dy crazy....I've hitting some response writes to prove I'm in a
section of code where it should be redim'ing preserving the temp
array and resizing it etc....it doesn't seem to be growing, so I
changed the increment to 10 and still it comes out with a
response.write UBound(myArray, 2) as 1 - I mean - WHAT THE HELL!!!
arrghhhh....
Are you using a dynamic array? Do you know how many items you'll be
removing? if so, why not initially redim the array to the intended size?
repeated "redim preserve"s is not very efficient. Actually, I've just
had a brainstorm for a quicker way to do it. Here is some code
illustrating both ways to remove a single item from an array:
<%
option explicit
dim ar
ar=array("a","b","c")
response.write join(ar,", ") & "<BR>"
ar=remove(ar,"b")
response.write join(ar,", ")
ar=array("a","b","c")
response.write "<BR>" & join(ar,", ") & "<BR>"
ar=remove2(ar,"c")
response.write join(ar,", ")
'-------------------------------------------
function remove(byval arsrc,item)
dim ardest(), i, j, curitem
redim ardest(ubound(arsrc)-1)
j=0
for i = 0 to ubound(arsrc)
curitem=arsrc(i)
if curitem<>item then
ardest(j) = curitem
j=j+1
end if
next
remove=ardest
end function
'-------------------------------------------
function remove2(byval arsrc,item)
dim s, ardest
s=join(arsrc,"|") & "|"
s=replace(s,item & "|","")
ardest=split(left(s,len(s)-1),"|")
remove2=ardest
end function
%>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.