# Tricky question

## Recommended Posts

Hey,

I have a bunch of loops comparing certain arrays, such as

for \$x = 0 to 4

for \$y = 0 to 10

If \$Card1[\$x][\$y] == \$A[\$x][\$y] Or \$Card1[\$x][\$y] == 0 Then

\$Num = 1

Else

\$Num = 0

EndIf

Next

Next

for \$x = 0 to 4

for \$y = 0 to 10

If \$Card1[\$x][\$y] == \$2[\$x][\$y] Or \$Card1[\$x][\$y] == 0 Then

\$Num = 2

Else

\$Num = 0

EndIf

Next

Next

Etc.

The only difference is :

\$A[\$x][\$y]

The A switches to 2, then 3, etc.

I was wondering if there was a way I could put all these loops into one, and simply change that using a variable.

Any help would be great,

Thanks

##### Share on other sites

Is this what you were looking for?

```For \$x = 0 To 4
For \$y = 0 To 10
If \$Card1[\$x][\$y] == \$A[\$x][\$y] Or \$Card1[\$x][\$y] == 0 Then
\$Num = 1
Else
\$Num = 0
EndIf
If \$Card1[\$x][\$y] == \$2[\$x][\$y] Or \$Card1[\$x][\$y] == 0 Then
\$Num = 2
Else
\$Num = 0
EndIf
Next
Next```

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

##### Share on other sites

You can do loops on variable names using Eval(). That might help you.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...