请问VB当中当list1里的数字到list2中后按大小排列的代码该怎么写?
如图所示,list1中的数字到list2中后按从小到大排列,然后在list1中加入新数字,左右互换后,两边的数字依然按从小到大排列。跪求大神代码怎么写。PrivateSu...
如图所示,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
这是我前面已经写好的代码,就是比大小的代码如何写不知道,跪求大神解答。 展开
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
这是我前面已经写好的代码,就是比大小的代码如何写不知道,跪求大神解答。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询