7,763
社区成员
发帖
与我相关
我的任务
分享
'记录集法(字符,数字通用)
Sub RecordsetSort(anyInput As Variant, Optional Sort As String = "ASC")
Dim rs As New Recordset
Dim i As Long
With rs
.Fields.Append "FSort", adVarChar, 50
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open
For i = LBound(anyInput) To UBound(anyInput)
.AddNew
!FSort = anyInput(i)
.Update
Next
'.UpdateBatch
.Sort = "FSort " & Sort
For i = LBound(anyInput) To UBound(anyInput)
anyInput(i) = !FSort
.MoveNext
Next
End With
Set rs = Nothing
End Sub