For i=0 To max-1
flag=newstr(i)
For j=i+1 To max-1
If newstr(j)=flag And flag<>"" Then
newstr(j)=""
End If
Next
If newstr(i)<>"" Then
If newstr(i)=newstr(max-1) Then
Response.Write newstr(i)
Else
Response.Write newstr(i)&","
End If
End If
不过这样写就可以了。
<%
Dim charstr
charstr="1,1,1,2,2,2,3,3,4,5,7,7,8,9"
Dim newstr
newstr=Split(charstr,",")
max=UBound(newstr)
Dim i,j,flag
For i=0 To max-1
flag=newstr(i)
For j=i+1 To max-1
If newstr(j)=flag And flag<>"" Then
newstr(j)=""
End If
Next
If newstr(i)<>"" Then
Response.Write newstr(i)&","
End If
Next
%>
str = "1,1,1,2,2,3,4,5,6,6,6,7"
DistinctStr = ""
for i = 1 to Len(str)
word = right(left(str,i),1)
if word<>"," then
if instr(DistinctStr,word)<=0 then
DistinctStr = DistinctStr&word&","
end if
end if
next
DistinctStr = Left(DistinctStr,Len(DistinctStr)-1)
Response.Write("原 串:"&str&"<br>去除重复:"&DistinctStr)
%>