alirezahassan Active Member Licensed User Longtime User Nov 1, 2021 #1 hi all, I have a (For). I want to reverse the number. For example in C language:[CODE lang="c" title="C"]for(int i = 10; i>=0; i--)[/CODE] i use B4X: for i = 10 to 0 next but it doesn't work. what should i do? Last edited: Nov 1, 2021
hi all, I have a (For). I want to reverse the number. For example in C language:[CODE lang="c" title="C"]for(int i = 10; i>=0; i--)[/CODE] i use B4X: for i = 10 to 0 next but it doesn't work. what should i do?
roumei Active Member Licensed User Nov 1, 2021 #2 B4X: For i = 10 To 0 Step -1 Log(i) Next Upvote 4 Solution
Jmu5667 Well-Known Member Licensed User Longtime User Nov 1, 2021 #3 alirezahassan said: hi all, I have a (For). I want to reverse the number. For example in C language:[CODE lang="c" title="C"]for(int i = 10; i>=0; i--)[/CODE] i use B4X: for i = 10 to 0 next but it doesn't work. what should i do? Click to expand... Code: For i = 10 To 0 Step -1 Log(i) Next Upvote 0
alirezahassan said: hi all, I have a (For). I want to reverse the number. For example in C language:[CODE lang="c" title="C"]for(int i = 10; i>=0; i--)[/CODE] i use B4X: for i = 10 to 0 next but it doesn't work. what should i do? Click to expand... Code: For i = 10 To 0 Step -1 Log(i) Next
alirezahassan Active Member Licensed User Longtime User Nov 1, 2021 #4 Why this mistake? What is correct? B4X: For i = 10 To 0 Step +3 Log(i) Next It Logs it correctly. B4X: For i = 10 To 0 Step -3 Log(i) Next Upvote 0
Why this mistake? What is correct? B4X: For i = 10 To 0 Step +3 Log(i) Next It Logs it correctly. B4X: For i = 10 To 0 Step -3 Log(i) Next
Jmu5667 Well-Known Member Licensed User Longtime User Nov 1, 2021 #5 alirezahassan said: Why this mistake? What is correct? B4X: For i = 10 To 0 Step +3 Log(i) Next It Logs it correctly. B4X: For i = 10 To 0 Step -3 Log(i) Next Click to expand... Counting backwards use -n, n = step count Upvote 0
alirezahassan said: Why this mistake? What is correct? B4X: For i = 10 To 0 Step +3 Log(i) Next It Logs it correctly. B4X: For i = 10 To 0 Step -3 Log(i) Next Click to expand... Counting backwards use -n, n = step count
alirezahassan Active Member Licensed User Longtime User Nov 1, 2021 #6 Is there no way? B4X: For i = 10 To 0 Step +3 Log(i) Next Upvote 0
klaus Expert Licensed User Longtime User Nov 1, 2021 #7 What exactly do you want to do ? If you want to go from 10 down to 0, therefor, the Step MUST be negative: For i = 10 To 0 Step -3 If you want to go from 0 to 10 the Step must be positive: For i = 0 To 10 Step 3 If no Step is given, it is 1 by default. If you want a Steop of -1 you must write it. Upvote 0
What exactly do you want to do ? If you want to go from 10 down to 0, therefor, the Step MUST be negative: For i = 10 To 0 Step -3 If you want to go from 0 to 10 the Step must be positive: For i = 0 To 10 Step 3 If no Step is given, it is 1 by default. If you want a Steop of -1 you must write it.
Daestrum Expert Licensed User Longtime User Nov 1, 2021 #8 Maybe the fact if you make the Step +3 you get a syntax error, obviously it doesn't like the + sign If you really want to use a plus sign you must write Step 0+3 Upvote 0
Maybe the fact if you make the Step +3 you get a syntax error, obviously it doesn't like the + sign If you really want to use a plus sign you must write Step 0+3