在一个字符串中显示复选框选择(Visual Basic)

时间:2013-11-12 03:40:30

标签: vb.net

尝试将所有选定项目的结果显示在一个消息框字符串中。到目前为止我有这个,我知道这是错的。如果重要,则通过文本文件和对象填充此列表。

Dim cBike As String = "
    For Each cBike In clbBikes.Items
        cBike = clbBikes.SelectedItem & ", "
    Next
    MsgBox(("Your selection of: " & cBike))

请帮助,我的讲师将永远服用并帮助那些需要更多的人。

2 个答案:

答案 0 :(得分:0)

您需要实际连接字符串:

For Each cBike In clbBikes.Items
    cBike = cBike + clbBikes.SelectedItem & ", "
Next

您还需要删除最后一个逗号

If (xml.Length > 2) Then
    cBike = cBike.Remove(cBike.Length - 2, 2)
End If

答案 1 :(得分:0)

你可能意味着CheckedItems

 Dim cBike As String = ""
 For Each chk As String In clbBikes.CheckedItems
    cBike &= chk & ", "
 Next

 MessageBox.Show("Your selection of: " & cBike)