Kerry 发表于 2007-9-5 07:50:30

如何对组合框排序?

有没有办法按字母顺序对组合框排序

Bryco 发表于 2007-9-5 08:02:20

作者未知Public Function CBsort(CB As ComboBox)
' Sort the Combobox
    Dim CBvar As Variant
    For I = 0 To CB.ListCount - 2
   
      If CB.List(I) > CB.List(I + 1) Then
            CBvar = CB.List(I)
            CB.List(I) = CB.List(I + 1)
            CB.List(I + 1) = CBvar
            I = -1
      End If
    Next I
End Function

Keith™ 发表于 2007-9-5 08:19:50

谢谢你的代码
只有这需要很长时间才能对90.00000个项目中的列表进行排序

Keith™ 发表于 2007-9-5 08:24:29

在将信息添加到组合框之前对其进行排序 什么'你的代码看起来像什么 你能发一个片段吗?

Keith™ 发表于 2007-9-5 08:32:03

将项目读入数组、对数组排序然后将数组添加到组合框中可能更容易/更快

Bryco 发表于 2007-9-5 09:22:35


有多少??

Keith™ 发表于 2007-9-5 09:40:32

http://vbnet.mvps.org/index.html?code/sort/qsoverview.htm快速排序可能是其中之一,但肯定需要几秒钟的时间

Keith™ 发表于 2007-9-5 10:06:48


有多少
没错
为什么你想/需要在一个组合框中添加9000000个项目

Keith™ 发表于 2007-9-5 13:25:51

简单的解决方案是在设计时在IDE中将Sorted属性设置为True
在运行时,组合框排序属性是只读的,因此需要在运行代码之前对其进行设置。

Bryco 发表于 2007-9-5 13:30:31


但VBA中的组合框不'没有排序选项。(除非它被称为其他东西??)
页: [1] 2
查看完整版本: 如何对组合框排序?