vba - lAdding files to a two column listbox -
i trying add together files list box in same way added when files attached email, in 2 columns able address each file uniquely. using access vba , not know if possible. help appreciated. thanks
try mapping indices of items in listbox files using separate array/collection/dictionary. then, when item selected, can utilize item's index link
i tried below, works perfectly. userform code:
private d dictionary private sub userform_initialize() set d = new dictionary 'populate list box, , add together items dictionary = 1 3 listbox1 d.add .listcount, "link" & .additem 0 .list(.listcount - 1) = "hello world" end next end sub 'update label1's value based of listbox's selected item private sub listbox1_change() listbox1 if .listindex <> -1 label1.caption = d.item(.listindex) end if end end sub and userform looked this: (listbox named listbox1, , label named label1):
example:
if have problems using dictionary object, need add together reference "microsoft scripting runtime". collection-type can replace dictionary in case (an array/collection)
vba
No comments:
Post a Comment