For i=0 to... question

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

For i=0 to... question

Postby juhuwoorps » Tue Mar 09, 2010 5:42 pm

Hello to all!
I have a question about the for i=0 to... loop

if I try this code:

Code: Select all
for i=0 to 10
MsgBox="number="+CStr(i)
i=i+5
Next


I get as expexted the number 0 in the message.But when I click OK I get as second number 6 instead expected 5.

Why is this so?


Thanks in advance!

juhuwoorps
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby ShadowHunter » Tue Mar 09, 2010 5:49 pm

Hi,

What happens is this:

1. i = 0
2. MsgBox "0"
3. 0 = 0 + 5 --> i = 5
4. Next (increase i with 1)
5. 5 + 1 = 6 --> i = 6

The next increases i with one :D

Just do this, it will display 0, 5 and 10

For i = 0 to 10 Step 5
MsgBox "Number" & i
Next

With best regards,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby juhuwoorps » Tue Mar 09, 2010 6:13 pm

i have tried it witj step but i doesnt have worked for me.
I know step from php so I tried it here also but it have doesnt workes for me.but i try it a second time :)


Edit:
Great! It works know! I just forgot and space between step and 5 :(
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests

cron