Results 1 to 5 of 5

Thread: For Loops

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    23

    For Loops

    Basically, I really can't get this to work!

    I've got this code:

    VB Code:
    1. If Index = 0 Then txtMegaDrive.Text = "Sonic 1"
    VB Code:
    1. If Index = 0 Then txtMegaDrive.BackColor = &HFFC0C0

    VB Code:
    1. If Index = 1 Then txtMegaDrive.Text = "Sonic 3D"
    VB Code:
    1. If Index = 1 Then txtMegaDrive.BackColor = &HFF8080

    etc until index 8. Is it possible to change this stuff into a For Loop?
    I got stuck after writing:
    Dim Count As Integer'
    For Count = 0 To 7
    Next Count

    Thanks very much

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: For Loops

    This will change things once. If You use the loop, change the select to Count
    and it will do all of them each time. I wasn't sure if that is what you wanted to do, though.
    VB Code:
    1. Select Case Index
    2. case 0
    3.    txtMegaDrive.Text = "Sonic 1"
    4.   txtMegaDrive.BackColor = &HFFC0C0
    5. case 1
    6.   txtMegaDrive.Text = "Sonic 3D"
    7.   txtMegaDrive.BackColor = &HFF8080
    8. ':
    9. ':
    10. end select

  3. #3
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: For Loops

    Quote Originally Posted by BatmanSpider
    Basically, I really can't get this to work!

    I've got this code:

    VB Code:
    1. If Index = 0 Then txtMegaDrive.Text = "Sonic 1"
    VB Code:
    1. If Index = 0 Then txtMegaDrive.BackColor = &HFFC0C0

    VB Code:
    1. If Index = 1 Then txtMegaDrive.Text = "Sonic 3D"
    VB Code:
    1. If Index = 1 Then txtMegaDrive.BackColor = &HFF8080

    etc until index 8. Is it possible to change this stuff into a For Loop?
    I got stuck after writing:
    Dim Count As Integer'
    For Count = 0 To 7
    Next Count

    Thanks very much
    If the Text you are assigning and the color you are using are in an array then the loop will be appropriate.. otherwise.. useless...

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: For Loops

    Quote Originally Posted by moinkhan
    If the Text you are assigning and the color you are using are in an array then the loop will be appropriate.. otherwise.. useless...
    If they were in an array, the loop might also be useless:

    VB Code:
    1. txtMegaDrive.Text = MDriveText(Index)
    2. txtMegaDrive.BackColor = MDriveBColor(Index)
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: For Loops

    Quote Originally Posted by Mc Brain
    If they were in an array, the loop might also be useless:

    VB Code:
    1. txtMegaDrive.Text = MDriveText(Index)
    2. txtMegaDrive.BackColor = MDriveBColor(Index)

    exactly....

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