单击"降序"按钮,将组合框内的选项按降序排列,然后将按钮标题设置为"升序"? 10
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询