开发者

how do i add multiple columns to a listbox using mixed data types in vba?

I'm trying to add items (multiple columns) to a listbox. As I understand, in order to add multiple columns, you normally send them as strings like so:

Listbox.AddItem("column1;column2;column3")

This works for me just fine. But how do I add multiple columns when the item is not a string? I've tried things like:

Listbox.AddItem("name"; txtAge.Value)

and

Listbox.AddItem("name; txtAge.Value")

and even

Listbox.AddI开发者_高级运维tem("name; Me![txtAge]")

None are working. I wasn't able to find anything on the web. What is the correct syntax?


You have to cast the txtAge to a String....

    LTrim(str(txtAge.value)) 

or

    CStr(txtAge.value)


You are almost there, just a little edit though:

Listbox.AddItem("name; " & txtAge.Value)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜