Add items to a multi-column List Box

余生长醉 提交于 2019-12-11 10:39:37

问题


Can someone please give me a simple example of how to add values to a multi-column listbox in vbscript. For example I have 4 columns and I'd like to add a row.

http://msdn.microsoft.com/en-us/library/office/ff869962%28v=office.15%29.aspx I tried this example but it kept telling me that it could not find the member .List.

I am using vbscript in MS Access. I have a form with a listbox. I want to populate this listbox with the textbox values I have such that when I click on Add, the values in the textboxes are added to the listbox under their particular column.

I have been searching to no avail - I haven't found one example that works or at least am I missing some import?


回答1:


I remember I have done this once and came to this solution:

Private Sub test()
    Me.lboTest.RowSourceType = "Value List"
    Me.lboTest.BoundColumn = 1
    Me.lboTest.ColumnCount = 2
    Me.lboTest.RowSource = "0;red;1;green;2;yellow;3;blue"
End Sub

Assemble the string beforehand with ; (or read it and append values, then write it back).
I don't know if there is any other way.

Btw., just to make sure you get this right: VBA and VBScript are different things. If you write this code within Access itself, you are using VBA, not VBScript.



来源:https://stackoverflow.com/questions/22399692/add-items-to-a-multi-column-list-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!