Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
arrays
#1
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
Reply
#2
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.
Reply
#3
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.
Reply
#4
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.
Reply
#5
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.
Reply
#6
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 Smile
Reply
#7
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.
Reply
#8
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...
Reply
#9
i get what your saying now. the num(4)=3 should be insde the for...next. that shouldnt slow it down much would it?
Reply
#10
Having it inside the loop slows it down a little. What he's saying is it's better to have to outside the loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)