vba中ListBox控件的使用

给ListBox添加内容

If CheckBox8 = True Then---------------------------checkbox控件被选中

    For i = 0 To ListBox1.ListCount - 1--------------循环将值赋到ListBox中
        If i < ListBox1.ListCount Then
    '        If ListBox1.Selected(i) Then
    '            ListBox1.RemoveItem (i) ---------------clear   selected row 删除选中内容
                Me.ListBox1.Selected(i) = True----------Me只有在同一个页面的时候才用  sheet5.ListBox1.Selected(i) = True 适用所有情况。
    '            i = i - 1
    '        End If
        End If
    Next

Else
    For i = 0 To ListBox1.ListCount - 1
        If i < ListBox1.ListCount Then
   
                Me.ListBox1.Selected(i) = False
   
        End If
    Next
   
End If

 

通过调节ListBox属性调节ListBox多选或者单选ListSytle等改变内容的输出形式。

 

 

 

 

 

posted @ 2013-11-08 16:25  笑看天下  阅读(15336)  评论(0编辑  收藏  举报