|
-
Apr 7th, 2006, 11:27 AM
#1
Thread Starter
Fanatic Member
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.
-
Apr 7th, 2006, 11:34 AM
#2
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?
-
Apr 7th, 2006, 11:38 AM
#3
Thread Starter
Fanatic Member
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.
-
Apr 7th, 2006, 12:17 PM
#4
Thread Starter
Fanatic Member
Re: for loop problem
sorry , i put them the wrong way around when i first posted it, its right now
-
Apr 7th, 2006, 12:56 PM
#5
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:
dim c(1 to 50) as creature
That way you can use the loop as follows:
VB Code:
Dim N As Integer
For N = 2 To 50
c(N).xv =c(1).xv
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!
-
Apr 8th, 2006, 07:26 AM
#6
Thread Starter
Fanatic Member
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
-
Apr 8th, 2006, 03:47 PM
#7
Re: for loop problem
If that is so, the only option you have is:
VB Code:
c2.xv = c1.xv
c3.xv = c1.xv
'and so on until
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!
-
Apr 9th, 2006, 12:08 PM
#8
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|