Private Sub Class_Initialize tMin =0 tMax =0 tStr ="0" tLength =0 tSortStr="" End Sub
""//获得最小值 Property Get cMin If tMin=0 Then Dim sStr If tSortStr="" Then sStr=Split(cSort,",") Else sStr=Split(tSortStr,",") End If tMin=sStr(0) End If cMin=tMin End Property
""//获得最大值 Property Get cMax If tMax=0 Then Dim sStr If tSortStr="" Then sStr=Split(cSort,",") Else sStr=Split(tSortStr,",") End If tMax=sStr(Ubound(sStr)) End If cMax=tMax End Property
Property Get Length If tStr="" Or tStr=0 Then Length =0 Else tLength =Ubound(Split(tStr,","))+1 Length =tLength End If End Property
""//将数组串赋给属性 Property Let srcStr(str) If str="" Then tStr="0" Else tStr=str End If End Property
""//排序,倒序 Public Function cSort Dim Arr,i Redim Arr(Ubound(Split(tStr,","))) Dim tmp,j For i=0 to Ubound(Arr) Arr(i)=CDBL(Split(tStr,",")(i)) Next For I= 0 to Ubound(Arr) For j=i+1 to Ubound(Arr) If Arr(i)<Arr(j) Then tmp =Arr(i) Arr(i) =Arr(j) Arr(j) =tmp End If Next Next tSortStr=Join(Arr,",") cSort=tSortStr End Function
""//顺序 Public Function cSortAsc Dim tmp,i,Arr If tSortStr="" Then tmp=cSort Else tmp=tSortStr End If Redim Arr(Ubound(Split(tmp,","))) Arr=Split(tmp,",") For i= Ubound(Arr) to 0 Step -1 cSortAsc=cSortAsc & Arr(i) & "," Next cSortAsc=Left(cSortAsc,Len(cSortAsc)-1) End Function
""//在未尾加元素 Public Function AddItem(str) If tStr="" OR tStr="0" Then tStr=str Else tStr=tStr & "," & str End If tMin =0 tMax =0 tSortStr="" tLength =tLength + 1 AddItem =tStr End Function
""//前部加元素 Public Function AddItemBefore(str) If tStr="" OR tStr="0" Then tStr=str Else tStr=str & "," & tStr End If tMin =0 tMax =0 tSortStr="" tLength =tLength + 1 AddItemBefore=tStr End Function
""//在索引位置加元素 Public Function AddItemI(index,str) If index>=Length Then AddItem(str) Exit Function End If If index<=0 Then AddItemBefore(str) Exit Function End if
Dim Arr,i,tmps Redim Arr(Ubound(Split(tStr,","))) Arr=Split(tStr,",") For i=0 to index-1 tmps=tmps & Arr(i) & "," Next tmps=tmps & str & "," For i=index to Ubound(Arr) tmps=tmps & Arr(i) & "," Next tmps =Left(tmps,Len(tmps)-1) tStr =tmps tSortStr="" tLength =tLength+1 tMin =0 tMax =0 AddItemI=tStr End Function
""//在索引位置移除元素 Public Function RemoveItemI(index) If index>=Length Or index<=0 Then Exit Function End If
Dim Arr,i,tmps Redim Arr(Ubound(Split(tStr,","))) Arr=Split(tStr,",") For i=0 to Ubound(Arr) If i<>index Then tmps=tmps & Arr(i) & "," Next tmps=tmps & str & "," tmps =Left(tmps,Len(tmps)-1) tStr =tmps tSortStr="" tLength =0 tMin =0 tMax =0 RemoveItemI=tStr End Function