首页上一页 1 下一页尾页 2 条记录 1/1页
Vb ListBox竖向转横向问题
发表在VB答疑区
2011-06-13
是否精华
是
否
版块置顶:
是
否
在List1中有一组动态数据(0~20个数),我想把List1的数据横放在List2中,即
List1(Lt1):
1
2
3
4
5
4
7
8
9
……
20
结果List2(Lt2):
1 2 3 4 5 6 7 8 9 10 …… 20
程序代码如下:
Private Sub Command1_Click()
Dim a as Integer
a=Lt1.ListCount - 1
Select Case a
Case -1
Lt2.AddItem "0"
Case 0
Lt2.AddItem Lt1.List(0)
Case 1
Lt2.AddItem Lt1.List(0) & " " & Lt1.List(1)
Case 2
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2)
Case 3
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3)
Case 4
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3) & " " lt1.List(4)
……
Case19
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3) & " " lt1.List(4)& ……lt1.List(19)
End Select
End Sub
在编程中,每次写到……& " " Lt1.List(2)时,都会有一个提示框提示:“编译错误:缺少:语句结束”。请问各位老师,我的编程错在哪里,怎样才能实现我的原想。谢谢!
List1(Lt1):
1
2
3
4
5
4
7
8
9
……
20
结果List2(Lt2):
1 2 3 4 5 6 7 8 9 10 …… 20
程序代码如下:
Private Sub Command1_Click()
Dim a as Integer
a=Lt1.ListCount - 1
Select Case a
Case -1
Lt2.AddItem "0"
Case 0
Lt2.AddItem Lt1.List(0)
Case 1
Lt2.AddItem Lt1.List(0) & " " & Lt1.List(1)
Case 2
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2)
Case 3
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3)
Case 4
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3) & " " lt1.List(4)
……
Case19
Lt2.AddItem Lt1.List(0) & " " & lt1.List(1) & " " lt1.List(2) & " " lt1.List(3) & " " lt1.List(4)& ……lt1.List(19)
End Select
End Sub
在编程中,每次写到……& " " Lt1.List(2)时,都会有一个提示框提示:“编译错误:缺少:语句结束”。请问各位老师,我的编程错在哪里,怎样才能实现我的原想。谢谢!