Posts: 1,057
Threads: 156
Joined: Aug 2003
can i goto a point in an array and change it's vaule? if so how? example
for i = 1 to 6
num(i)=i
next
i want to change num(3)=3 to num(3)=4
Posts: 3,343
Threads: 83
Joined: Mar 2003
You just answered your own question...
to change num(3) to 4, just put the line
num(3) = 4
where you want it. If you want them all to be one bigger, then
for i = 1 to 6
num(i) = i + 1
next i
Now, go rtfm.
Posts: 1,813
Threads: 284
Joined: Mar 2003
I suggest "RTFM" be put in the banned-word list, and the auto-replacement text for it should be "RTFM [
http://www.qbasicnews.com/manual]" or wherever it's located... cuz how do newbies know what rtfm means?
earn.
Posts: 1,057
Threads: 156
Joined: Aug 2003
well tfm i have did say i could do that num(3)=4
Code:
FOR i = 1 TO 6
num(i) = i
NEXT
FOR i = 1 TO 6
num(4) = 3
PRINT num(i)
NEXT
ok i am pround to say i know very little about qb but i'm learning. and learings half the battle.
Posts: 3,368
Threads: 195
Joined: Jan 2003
And it was right.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 3,343
Threads: 83
Joined: Mar 2003
What is this?
Code:
FOR i = 1 TO 6
num(4) = 3
PRINT num(i)
NEXT
You don't need to make num(4) = 3 six times over. It can remember it by itself, it's a computer
Posts: 1,057
Threads: 156
Joined: Aug 2003
it's an example of replacing a value. the out put is 1 2 3 3 5 6 insted of 1 2 3 4 5.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Code:
FOR i = 1 TO 6
num(i) = i)
NEXT i
num(4) = 3
FOR i = 1 to 6
PRINT num(i)
NEXT i
Much more efficient than doing the same thing 6 times...
Posts: 1,057
Threads: 156
Joined: Aug 2003
i get what your saying now. the num(4)=3 should be insde the for...next. that shouldnt slow it down much would it?
Posts: 1,272
Threads: 36
Joined: Feb 2003
Having it inside the loop slows it down a little. What he's saying is it's better to have to outside the loop.