//可用于对一组坐标进行排序记录的是X坐标,后面跟随的是FindPic的图片对应值 ,已经验证
Dim str="228,1|406,1|274,0|326,0|352,3|249,5|480,5|453,6|300,7|378,7|427,8|"
Dim strArrary=Split(str,"|")
Dim JianGeFuHao="|"
Dim i,j,X,str2
Dim DX,XD,dd,xx,JN,jj,PhoneNum
Dim temp
Dim txt="123|123|456|456|789|789"
//字符串删除重复
Call ShaiXuan(txt, JianGeFuHao)
Function ShaiXuan(fist,JianGeFuHao)
Dim sArray = Split(fist, JianGeFuHao)
Dim j,k,str1
For j = 0 to UBound(sArray)
For i = 0 To j
If sArray(j) = sArray(i) Then
k = k + 1
End If
If j = UBound(sArray) Then
k = 0
End If
Next
If k = 1 Then
str1 = str1 & sArray(j) & JianGeFuHao
End If
k = 0
Next
TracePrint str1
End Function
//方法一:存在一定问题是借鉴网上资源
Call PaiXuXu(strArrary,JianGeFuHao)
//对字符串进行排序排序
Function PaiXu(str,JianGeFuHao)
//UBOUND (strArrary)
For i = 0 To UBOUND(strArrary) - 1
DX = Split(strArrary(i), ",")
dd=DX(0)
For j = 0 To UBOUND(strArrary) - 1
XD = Split(strArrary(j), ",")
xx=XD(0)
If Int(dd) < Int(xx) Then
//TracePrint strArrary(i),strArrary(j)
X = strArrary(i) : strArrary(i) = strArrary(j) : strArrary(j) = X
End If
Next
Next
For i = 0 To UBOUND(strArrary) - 1
str2 = str2 & strArrary(i) & "|"
Next
TracePrint str2
For i = 0 To UBOUND(strArrary) - 1
JN = Split(strArrary(i), ",")
jj = JN(1)
PhoneNum = PhoneNum & jj
Next
TracePrint PhoneNum
End Function
//方法二:自己使用方法一发现不好用,自己改编通过冒泡排序方法实现
Function PaiXuXu(str, JianGeFuHao)
//strArrary = Split(str, JianGeFuHao)
For i = 0 To UBOUND(strArrary) - 1
For j = 0 To UBOUND(strArrary) - 2 - i
DX = Split(strArrary(j), ",")
dd = DX(0)
XD = Split(strArrary(j+1), ",")
xx = XD(0)
If Int(dd) > Int(xx) Then //将>改成<,可实现从大到小排列
temp = strArrary(j)
strArrary(j) = strArrary(j + 1)
strArrary(j+1)=temp
//X = strArrary(j) : strArrary(j) = strArrary(j+1) : strArrary(j+1) = X
End If
Next
Next
For i = 0 To UBOUND(strArrary) - 1
JN = Split(strArrary(i), ",")
jj = JN(1)
PhoneNum = PhoneNum & jj
Next
TracePrint PhoneNum
End Function
如果对你有帮助请点赞