Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are trying to store Inetger Data Types as Objects in a Collection, no
good. Why don't you just put your integers into an Array instead. Dim MyArray(3) As Variant Dim i1 As Integer Dim i2 As Integer Dim i3 As Integer Dim i4 As Integer i1 = 10 i2 = 20 i3 = 30 i4 = 40 MyArray = Array(i1, i2, i3, i4) or MyArray(0) = 10 MyArray(1) = 20 MyArray(2) = 30 MyArray(3) = 40 Hope this helps! If so, click "YES" below. -- Cheers, Ryan "Rich" wrote: I haven't worked with vba collection objects for a while and have sort of forgotten some of the properties. Here is a code sample using a collection object and the error I am getting when I try to perform a particular operation: I am basically assigning values to the given Integer vars below and then storing these vars (or their values) in the collection object col. Then I want to change the value of one of the collection items but I get an error -- as depicted beolw. Is there a way to get around this? Or should I create class objects with properties instead and create my own collection class? Dim col As New Collection Dim i1 As Integer, i2 As Integer, i3 As Integer, i4 As Integer i1 = 10 i2 = 20 i3 = 30 i4 = 40 col.Add i1, "1" col.Add i2, "2" col.Add i3, "3" col.Add i4, "4" col("1") = 15 <--try to change value of this col itme - error here "object required" |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Collection Object | Excel Programming | |||
Collection Object | Excel Programming | |||
How to track object index in object collection | Excel Programming | |||
Adding Name object to a collection does not add an object | Excel Programming |