网络编程
位置:首页>> 网络编程>> Asp编程>> asp数组去重复和数组排序

asp数组去重复和数组排序

  发布时间:2008-10-30 12:51:00 

标签:数组,排序,字符串,asp

数组去重复和数组排序


'数组名次
Function Sort(ary,stra)
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For i = 0 to UBound(ary)
If i = UBound(ary) Then Exit For
If CDbl(ary(i))<CDbl(ary(i+1)) Then
FirstValue = CDbl(ary(i))
SecondValue = CDbl(ary(i+1))
ary(i) = SecondValue
ary(i+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
sort=0
For j=0 To UBound(ary)
If CDbl(ary(j))=CDbl(stra) Then 
Sort=j+1
End If 
Next 
End Function

将字符串数组去掉重复项

Function clearrepeat(arrstr)
For k=0 To UBound(arrstr)
If k=0 Then 
arr=arrstr(k)
Else
arr=arr&","&arrstr(k)
End If 
Next 
Dim tmp,tmp2,i,j 
tmp3="" 
tmp=Split(arr,",") 
For i=0 To Ubound(tmp)-1 
For j=i+1 To Ubound(tmp) 
If UCase(Trim(tmp(i)))=UCase(Trim(tmp(j))) Then 
tmp(j)="" 
End If 
Next 
Next 
tmp2="" 
For i=0 To Ubound(tmp) 
If tmp(i)<>"" Then tmp2=tmp2&tmp(i)&"," 
Next 
clearrepeat=Split(Left(tmp2,Len(tmp2)-1),",")
End Function

Function arrSort(ary,stra)
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For i = 0 to UBound(ary)
If i = UBound(ary) Then Exit For
If CDbl(ary(i))<CDbl(ary(i+1)) Then
FirstValue = ary(i)
SecondValue = ary(i+1)
ary(i) = SecondValue
ary(i+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
arrsort=ary
End Function


 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com