Results 1 to 8 of 8

Thread: for loop problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    for loop problem

    what i need to do is:

    c2.xv = c1.xv
    c3.xv = c1.xv
    and so on until
    c50.xv = c1.xv

    i tried making a for loop but its not working. here it is

    Dim N As Integer
    For N = 2 To 50
    c(N).xv =c1.xv
    Next N

    could anyone tell me what is wrong with this please
    Last edited by killo; Apr 7th, 2006 at 11:43 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: for loop problem

    What is c1, c2, etc?

    What is .xv?

    What do you want done with the results of your loop? What kind of output?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: for loop problem

    c1, c2 and the rest are custom defined variables. here is how i done them:

    private type creature
    xv as double
    yv as double
    end type



    xv is x velocity and yv is y velocity

    i dont know what you mean by what kind of output do i want but i want my for loop to make c2.xv = c1.xv then c3.xv = c1.xv then c4.xv = c1.xv and so on until c50.xv = c1.xv
    Last edited by killo; Apr 7th, 2006 at 11:42 AM.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: for loop problem

    sorry , i put them the wrong way around when i first posted it, its right now

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: for loop problem

    instead of declaring several varialbels of type creature (c1, c2 ...), you should declare an array of type creature like

    VB Code:
    1. dim c(1 to 50) as creature
    That way you can use the loop as follows:
    VB Code:
    1. Dim N As Integer
    2. For N = 2 To 50
    3. c(N).xv =c(1).xv
    4. Next N
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: for loop problem

    but i have already used c1 in all the other code in the program and i dont want to have to go back and retype it all with c(1) instead of c1

  7. #7
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: for loop problem

    If that is so, the only option you have is:
    VB Code:
    1. c2.xv = c1.xv
    2. c3.xv = c1.xv
    3. 'and so on until
    4. c50.xv = c1.xv
    ..and that's a pain in the ***
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: for loop problem

    indeed it is

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