Results 1 to 4 of 4

Thread: frames and foreach..next loop

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    frames and foreach..next loop

    ok, I have a form that has about 10 frames that are all different background colors so that when I'm editing the program I can see them easily.. when the form loads, I just do a .BackColor change, but I want to try using a For Each Next loop so that I don't have to have 10 lines of code when I could just put a loop that does it for me instead.. I tried it; but I couldn't get it to work, and I've never used For Each loops before in VB, so I don't know how I could get it working. This is what I have so far for it:

    VB Code:
    1. Private Sub Form_Load()
    2.   'make frame background colors coordinated
    3.     For Each Frame In Form
    4.       Frame.BackColor = RGB(255, 255, 255)
    5.     Next
    6. End Sub

    Is this even possible, or am I just running in the wrong direction or something? Also, I know I could easily just put in the extra lines of code.. but I want it to be automated.. because that's cool and stuff.. It's just one of those programmer things.. no reason to really do it; you just do it to make it be awesome.

    edit: oh, I forgot to mention.. it gives me a type mismatch error..
    Last edited by kows; Nov 24th, 2003 at 11:58 AM.
    Like Archer? Check out some Sterling Archer quotes.

  2. #2

  3. #3
    Addicted Member Para80d's Avatar
    Join Date
    Oct 2003
    Location
    Denton, TX
    Posts
    160
    I've never used For Each before either, but if you use your frames as arrays, like frame(1), frame(2), etc...
    you could just run a for loop to do it


    VB Code:
    1. Private Sub Form_load()
    2.  
    3. For i = 0 to 9
    4.    frame(i).Backcolor = RGB(255, 255, 255)
    5. Next i
    6.  
    7. End Sub
    C++/VB6&.NET/QBasic/HTML/PHP/MySQL/SQLServer2k

    I'm the guy your little brother looks a lot alike. Tell your mom i said thanks.

    naked in vegas

  4. #4
    Addicted Member Para80d's Avatar
    Join Date
    Oct 2003
    Location
    Denton, TX
    Posts
    160
    use marty's.. he's smarter
    C++/VB6&.NET/QBasic/HTML/PHP/MySQL/SQLServer2k

    I'm the guy your little brother looks a lot alike. Tell your mom i said thanks.

    naked in vegas

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