Results 1 to 3 of 3

Help with looping through all elements in Class Array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question Help with looping through all elements in Class Array

    Hi guys,

    I am trying to loop through all the elements of my class array using the following

    Dim QueryField as cQueryField
    Dim k as integer
    
    Set QueryField = New cQueryField
    
    'POPULATE THE CLASS OBJECT ARRAY
    For k = LBound(myArray,2) to UBound(myArray,2)
    QueryField.PlantMake(k) = myArray(k,2)
    Next k
    
    'LOOP THROUGH THE CLASS OBJECT ARRAY AND DEBUG PRINT THE VALUES
    for i = UBound(QueryField.AllPlantMakes) To UBound(QueryField.AllPlantMakes)
    Debug.Print QueryField.AllPlantMakes(i)
    Next i

    Class
    My Class looks like the following:
    
    Private pAllPlantMakes
    
    Private Sub Class_Initializ()
    ReDim pAllPlantTypes(0)
    End Sub
    
    Public Property Get AllPlantMakes() as String()
    AllPlantMakes = pAllPlantMakes
    End Property
    
    Public Property Get PlantMake(index as Long) as String
    PlantMake = pAllPlantMakes(index)
    End Property
    
    Public Property Let PlantMake(index as Long, strValue as String)
    If index > Ubound(pAllPlantMakes) then ReDim Preserve pAllPlantMakes(index)
    pAllPlantMakes(index) = strValue
    End Poperty

    I keep receiving an error on the line: for i = UBound(QueryField.AllPlantMakes) To UBound(QueryField.AllPlantMakes)

    Why cant I loop through this 'class' array?

    Regards
    Jordan
    Last edited by jordan2322; 04-15-2013 at 06:47 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1