Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ok a quick question. I hava a nested for loop like say

 

for x=0 to 10

for y =0 to 10

if some condition is true array (x+1, y-1)=T AND array (x=2, y-2)=T

next y,x

 

is there a way to increment to counters concurently so that i can get rid of the inner conditiuon (which happens to be a lot more complex) I know you can do this in java and C but in VB i'm not sure. Anyone????

Posted

hi

 

for x=0 to 10

 

for y =0 to 10

 

if condition = true then

array (x+1, y-1)=T AND array (x=2, y- 2) =T

end if

 

next y

 

next x

 

Like this?

 

Your question is not so clear, i think.

 

ByeZ

By

BiZ

Join The Brotherhood Of NOD
  • *Experts*
Posted

Squirm was saying that you can change the values of your x and y loop variables inside the loop, to fit your needs, if you really need to change the values (it's generally not a good idea).

 

If we knew *exactly* what you wanted (change the value of x or y OR change your "if condition = true" logic), we could offer more concrete help.

 

If you really mean to assign x the value of 2 in the loop, you could write:

for x=0 to 10
 for y =0 to 10
   if condition = true then 
     array (x+1, y-1)=T 
     array (x, y- 2) =T
     x = 2
   end if
 next y
next x

or maybe you want:

for x=0 to 10
 for y =0 to 10
   if condition = true then 
     array (x+1, y-1)=T 
     x = 2
     array (x, y- 2) =T
   end if
 next y
next x

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...