Re: How to store growiing list box values programatically by Perry
Perry
Tue Apr 17 17:11:03 CDT 2007
Here are two examples filling a listbox
1) using the additem() method without arrays
2) using an array to pass to the Column property of a listbox
(both same result)
example 1
With Me.ListBox1
.AddItem "apples1"
.List(.ListCount - 1, 1) = "pears1"
.List(.ListCount - 1, 2) = "bananas1"
.AddItem "apples2"
.List(.ListCount - 1, 1) = "pears2"
.List(.ListCount - 1, 2) = "bananas2"
.AddItem "apples3"
.List(.ListCount - 1, 1) = "pears3"
.List(.ListCount - 1, 2) = "bananas3"
End With
example 2
Dim icnt As Integer
Dim arr()
For x = 1 To 3
ReDim Preserve arr(2, icnt)
arr(0, icnt) = "apples" & (icnt + 1)
arr(1, icnt) = "pears" & (icnt + 1)
arr(2, icnt) = "bananas" & (icnt + 1)
icnt = icnt + 1
Next
Me.ListBox1.Column = arr
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
"CS Hayes" <hayes.csmontypython@gmail.com> schreef in bericht
news:0125DE42-3EC1-45F0-B326-991C609F3AEE@microsoft.com...
>I need to store a list box's source in code (or a hidden table? I don't
> know.) The list grows. The user can add an item via form to the list.
>
> I have a form and on the add click I want to add a 5 column entry to the
> listbox
>
> I know of the "additem" key word but how do I add the 5 items to one row
>
> My items are like this: start (string), finish (string), difference
> (integer), multiplier (double), total (double)
> --
> Chris Hayes
> Still a beginner (only 12 years)