Listbox排序函数

Public Sub ReSort(L As Control)
Dim p%, PP%, C%, Pre$, S$, V&, NewPos%, CheckIt%
Dim TempL$, TempItemData&, S1$
For p = 0 To L.ListCount – 1
S = L.List(p)
For C = 1 To Len(S)
V = Val(Mid$(S, C))
If V > 0 Then Exit For
Next
If V > 0 Then
If C > 1 Then Pre = Left$(S, C – 1)
NewPos = -1
For PP = p + 1 To L.ListCount – 1
CheckIt = False
S1 = L.List(PP)
If Pre <> "" Then
If InStr(S1, Pre) = 1 Then CheckIt = True
Else
If Val(S1) > 0 Then CheckIt = True
End If
If CheckIt Then
If Val(Mid$(S1, C)) < V Then NewPos = PP
Else
Exit For
End If
Next
If NewPos > -1 Then
TempL = L.List(p)
TempItemData = L.ItemData(p)
L.RemoveItem (p)
L.AddItem TempL, NewPos
L.ItemData(L.NewIndex) = TempItemData
p = p – 1
End If
End If
Next
End Sub

转载请注明 :IT樵客

此条目发表在 程序设计 分类目录。将固定链接加入收藏夹。

关于 logger

2010年网络规划设计师证书寻挂靠!

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>