求救:关于LIST的问题

lujianyu1189 2004-06-13 01:27:18
使用一个List控件,增加如下几个项目,并带有checkbox
aaaaa
bbbbb
ccccc
ddddd
当选择了每一行的check后,要求在TEXT中显示出我所选的每一行的文字,并能自动显示出任意选择了行数.如:如果我选择了第一行和第三行,则在TEXT中显示aaaaa,ccccc,如果选择第二行和第三行,则在text中显示bbbbb,ccccc等,该如何解决呀
...全文
184 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2004-06-17
  • 打赏
  • 举报
回复
Option Explicit


Private Sub Command1_Click()
Text1.Text = ""
Dim A() As String, I As Integer, K As Integer
K = 0
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
K = K + 1
ReDim Preserve A(1 To K)
A(K) = List1.List(I)
End If
Next
Text1.Text = Join(A, ",")
Erase A
End Sub

Private Sub Form_Load()
Dim I As Integer
For I = 0 To 25
List1.AddItem String(5, Chr(I + 97))
Next
End Sub
edot 2004-06-17
  • 打赏
  • 举报
回复
kmzs 2004-06-13
  • 打赏
  • 举报
回复
TextBox.Text = List.Item(1)
online 2004-06-13
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Text1.Text = ""
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
If Text1.Text = "" Then
Text1.Text = List1.List(i)
Else
Text1.Text = List1.List(i) + "," + Text1.Text
End If
End If
Next i
End Sub

Private Sub Form_Load()
List1.AddItem "aaaa"
List1.AddItem "bbbb"
List1.AddItem "cccc"
List1.AddItem "dddd"
End Sub
Sunron128 2004-06-13
  • 打赏
  • 举报
回复
For i = 0 to List.ListCount -1
If List.Item(i).Checked then
TextBox.Text = List.Item(i)
End If
Next

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧