求高手指点:vb的listbox中其中几项在text输出

来源:百度知道 编辑:UC知道 时间:2024/06/25 09:59:23
如下程序

dim i%
for i=0 to list1.listcount-1
if list1.selected(i)=true then
print list1.list(i)
next

这个程序只能按列输出,我需要他们写出第一个后不换行接着写选中的第二个

例如,listbox内容如下:
1
2
3
4
5

我希望分别点选1、3、4后,输出效果为:1、3、4,而不是:
1
3
4

不知说明白了没,请高手指教!!!
谢谢您给我的指导,还是有点问题,因为我想将结果输出到textbox中,那么输出部分不能用print,该怎么写呢?

dim i%
for i=0 to list1.listcount-1
if list1.selected(i)=true then
print list1.list(i); '//print list1.list(i);加一个;这样就可以了。
next

如果是text的话。那么这样
if list1.selected(i)=true then
text1.text=text1.text & list1.list(i) '//这句变一下即可。
next

Dim i%
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
Print List1.List(i),
End If
Next

Private Sub List1_Click()
Dim i%
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
Print List1.List(i);
End If
Next
End Sub

我想,你是这个意思
'创建List1,text1,直接复制代码
Private Sub List1_Click()
If Text1.Text = "" Then
Text1.Text = List1.Text
Else
Text1.Text = Text1.Text & "、" & List1.Text
End If
End Sub

dim i%
for i=0 to list1.listcount-1
if list1.selected(i)=true then
print list1.list(i); '//print list1.list(i);
ne