乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Kerry

如何对组合框排序?

[复制链接]

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2007-9-5 13:42:30 | 显示全部楼层
嗯..我最近一直在VB工作..had'考虑到在VB和VBA中属性不同的事实…
让我看看我能想出什么
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2007-9-10 09:59:09 | 显示全部楼层
谢谢
  1.   'fill MyArray
  2.   For i = 1 To UBound(ComboBox1.List)
  3.     MyArray(i) = ComboBox1.List(i)
  4.   Next i
  5. QuickSort MyArray, LBound(MyArray), UBound(MyArray)
  6.   ComboBox1.Clear
  7.    'use sorted array to refill ComboBox
  8.   For i = 1 To UBound(MyArray)
  9.   If MyArray(i)  "" Then _
  10.     ComboBox1.AddItem MyArray(i)
  11.   Next i
  1. Private Sub QuickSort(strArray() As String, intBottom As Integer, intTop As Integer)
  2.   Dim strPivot As String, strTemp As String
  3.   Dim intBottomTemp As Integer, intTopTemp As Integer
  4.   intBottomTemp = intBottom
  5.   intTopTemp = intTop
  6.   strPivot = strArray((intBottom + intTop) \ 2)
  7.   While (intBottomTemp  intBottom)
  8.       intTopTemp = intTopTemp - 1
  9.     Wend
  10.    
  11.     If intBottomTemp  arr(Index + 1)) Xor descending Then
  12.                 ' if the items are not in order, swap them
  13.                 arr(Index) = arr(Index + 1)
  14.                 arr(Index + 1) = Value
  15.                 lastSwap = Index
  16.             End If
  17.         Next
  18.     Loop While lastSwap
  19. End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 02:20 , Processed in 0.270561 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表