请问VB当中当list1里的数字到list2中后按大小排列的代码该怎么写?如图所示,list1中的数字到list2中后按从小到大排列,然后在list1中加入新数字,左右互换后,两边的数字依然按从小到大排列.Private
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 03:32:24
请问VB当中当list1里的数字到list2中后按大小排列的代码该怎么写?如图所示,list1中的数字到list2中后按从小到大排列,然后在list1中加入新数字,左右互换后,两边的数字依然按从小到大排列.Private
请问VB当中当list1里的数字到list2中后按大小排列的代码该怎么写?
如图所示,list1中的数字到list2中后按从小到大排列,然后在list1中加入新数字,左右互换后,两边的数字依然按从小到大排列.
Private Sub command1_click()
Dim a As Integer
a = 0
Do While a < List1.ListCount
If List1.Selected(a) = True Then List2.AddItem List1.List(a):List1.RemoveItem a Else a = a + 1
Loop
End Sub
Private Sub command2_click()
Dim a As Integer
a = List1.ListCount - 1
For i = 0 To a
List2.AddItem List1.List1(i)
Next i
List1.Clear
End Sub
Private Sub command3_click()
Dim a As Integer
a = 0
Do While a < List2.ListCount
If List2.Selected(a) = True Then List1.AddItem List2.List(a):List2.RemoveItem a Else a = a + 1
Loop
End Sub
Private Sub Command4_Click()
Dim a As Integer
a = List2.ListCount - 1
For i = 0 To a
List1.AddItem List2.List(i)
Next i
List2.Clear
End Sub
Private Sub form_load()
List1.Clear
List2.Clear
List1.AddItem "7"
List1.AddItem "18"
List1.AddItem "25"
List1.AddItem "13000"
List1.AddItem "2000"
List1.AddItem "50000"
List1.AddItem "299"
Command1.Caption = ">"
Command2.Caption = ">>"
Command3.Caption = "<"
Command4.Caption = "<<"
Command5.Caption = "从小到大排序"
Command6.Caption = "左右互换"
Label2.Caption = "数字一"
Label3.Caption = "数字二"
Label1.Caption = "按Shift或Ctrl键可以多选"
End Sub
这是我前面已经写好的代码,就是比大小的代码如何写不知道,
请问VB当中当list1里的数字到list2中后按大小排列的代码该怎么写?如图所示,list1中的数字到list2中后按从小到大排列,然后在list1中加入新数字,左右互换后,两边的数字依然按从小到大排列.Private
在List2的属性中设置 Sorted 属性为 True 即可,这个属性是设置是否自动按字母顺序排列的属性.