Results 1 to 5 of 5

Thread: For Each Loops

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I'm trying to write a Class Module that will work in a For Each Loop, ie

    Code:
    Dim objMyClass as New clsMyClass
    
    Dim i as Variant
    
    For Each i in objMyClass
    
        MsgBox i
    
    Next i
    It's not a normal collection type thing (Actually I want it to define an elipse and the For each loop to go through every pixel on the border of that ellipse) How can I get this to work without having to have a collection inside my class (Filling a collection with all the points would be a huge waste of memory) I don't mind a bit of V-Table jiggery Pokery, any hints at all would be great.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    AFAIK, For each just works with objects, so you need to put a second object of another class to act as that object. Then have the items all refering to the same object, with property get/set

    But for this i would use for next instead and have the points in a simple property get/let to calculate the points, but i don't know if you actually need it to be an object.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    For each... only works with collections.
    Try it out with the classbuilder wizard, create a collection class, and a class of the type you created the collection for. The wizard automatically adds code for a for each loop
    Hope this helps

    Crazy D

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Not really, you can use with variable arrays too, we've discussed this out so don't bother anymore
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305
    you could do the math. I have it at home if you don't mind waiting about 8 hours till school's out. It's using the sin of the x and y to PSet a point on the picture box (you have to add stuff like (this is off the top of my head, here):

    Code:
    For i = 1 to 360 step .1
    x = 2000+(300 * Sin (500 * i))
    y = 2000+(150 * Sin (500 * i))
    Next i
    bob

Posting Permissions

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



Click Here to Expand Forum to Full Width