单击"降序"按钮,将组合框内的选项按降序排列,然后将按钮标题设置为"升序"? 10

 我来答
百度网友bdb9803
2011-05-18 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:53%
帮助的人:1亿
展开全部
Private Sub Command1_Click()
Dim c() As String, strTemp As String, i As Integer, j As Integer, k As String
ReDim c(Combo1.ListCount - 1)
k = Combo1.Text
For i = 0 To UBound(c)
c(i) = Combo1.List(i)
Next
For i = 0 To UBound(c)
For j = 0 To i
If Command1.Caption = "升序" Then
If c(j) > c(i) Then strTemp = c(j): c(j) = c(i): c(i) = strTemp
Else
If c(j) < c(i) Then strTemp = c(j): c(j) = c(i): c(i) = strTemp
End If
Next
Next
Combo1.Clear
For i = 0 To UBound(c)
Combo1.AddItem c(i)
If k = c(i) Then Combo1.ListIndex = i
Next
If Command1.Caption = "升序" Then Command1.Caption = "降序" Else Command1.Caption = "升序"
End Sub

Private Sub Form_Load()
Combo1.Clear
Combo1.AddItem "123"
Combo1.AddItem "45"
Combo1.AddItem "85"
Combo1.AddItem "235"
Combo1.AddItem "2634"
Combo1.AddItem "14"
Combo1.ListIndex = 0
Command1.Caption = "升序"
End Sub
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式