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
Printable View
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
What is c1, c2, etc?
What is .xv?
What do you want done with the results of your loop? What kind of output?
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
sorry , i put them the wrong way around when i first posted it, its right now
instead of declaring several varialbels of type creature (c1, c2 ...), you should declare an array of type creature like
That way you can use the loop as follows:VB Code:
dim c(1 to 50) as creature
VB Code:
Dim N As Integer For N = 2 To 50 c(N).xv =c(1).xv Next N
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
If that is so, the only option you have is:
..and that's a pain in the ***VB Code:
c2.xv = c1.xv c3.xv = c1.xv 'and so on until c50.xv = c1.xv
indeed it is