Wow, tricky but not impossible.
For the up and down, just create an array that transposes the rows and columns of the 12 original lines. You can then search them the same way you did before.
For the diagonals, you'd have to do some more work but it's still the same. You'd have an array and you'd pick a starting point, say upper left, and assign the elements starting from that point. For a simple 4X4, the assignment would look like this:
A1 B2 C3 D4
B1 C2 D3 E3
C1 D2 E2 F2
D1 E1 F1 G1
So then you'd have an array with String1 = A1; String2 = B1&B2; String3 = C1&C2&C3; etc. At that point, you can search them the normal way, i.e. you can use the function Instr() to find strings within the larger string.
For backward searches, you'd do the same for left-right, up-down, diagonal, but you'd reverse the order of the squares in your arrays FIRST and THEN search. Or better yet, keep the same arrays and reverse the search string only and then look for it in the unreversed arrays.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|