vb listbox每行里有文本加数字,如何按数字从大到小排序?
2个回答
展开全部
把ListBox的Sorted属性改为:True
追问
从大到小排序
追答
这个超出了VB的ListBox控件能力,不过可以使用自定义函数实现,如冒泡法排序,
限于回答所得,我只给你链接和方法,具体使用就看你的造化了,呵呵
点下面的链接,也可以去搜索“冒泡排序法”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
For I = 1 To List1.ListCount - 1
For j = 0 To I - 1
If Bjzfc(List1.List(j), List1.List(I)) Then
k = List1.List(I)
List1.List(I) = List1.List(j)
List1.List(j) = k
End If
Next j
Next I
End Sub
Private Sub Form_Load()
List1.AddItem "eio44251hret"
List1.AddItem "eio536hret"
List1.AddItem "eio968hret"
List1.AddItem "eio53h7et"
List1.AddItem "e43h7et"
List1.AddItem "e563h7et"
List1.AddItem "e63h7et"
List1.AddItem "e54878h7et"
List1.AddItem "e53h7et"
End Sub
Private Function Bjzfc(S1 As String, S2 As String) As Boolean
Dim I As Integer, T1 As Long, T2 As Long
For I = 1 To Len(S1)
If Val(Mid(S1, I, 1)) > 0 Then T1 = Val(Mid(S1, I)): Exit For
Next I
For I = 1 To Len(S1)
If Val(Mid(S2, I, 1)) > 0 Then T2 = Val(Mid(S2, I)): Exit For
Next I
If T1 > T2 Then Bjzfc = False Else Bjzfc = True
End Function
For I = 1 To List1.ListCount - 1
For j = 0 To I - 1
If Bjzfc(List1.List(j), List1.List(I)) Then
k = List1.List(I)
List1.List(I) = List1.List(j)
List1.List(j) = k
End If
Next j
Next I
End Sub
Private Sub Form_Load()
List1.AddItem "eio44251hret"
List1.AddItem "eio536hret"
List1.AddItem "eio968hret"
List1.AddItem "eio53h7et"
List1.AddItem "e43h7et"
List1.AddItem "e563h7et"
List1.AddItem "e63h7et"
List1.AddItem "e54878h7et"
List1.AddItem "e53h7et"
End Sub
Private Function Bjzfc(S1 As String, S2 As String) As Boolean
Dim I As Integer, T1 As Long, T2 As Long
For I = 1 To Len(S1)
If Val(Mid(S1, I, 1)) > 0 Then T1 = Val(Mid(S1, I)): Exit For
Next I
For I = 1 To Len(S1)
If Val(Mid(S2, I, 1)) > 0 Then T2 = Val(Mid(S2, I)): Exit For
Next I
If T1 > T2 Then Bjzfc = False Else Bjzfc = True
End Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询