Except for this one problem I have created a board game in VB6. There are four red pieces and one blue, with the board as per chequers, only the white squares in use. The sqaures are in an indexed control array (0 to 63) with only the white squares enabled.
I'm using Mouse_Down with Form_DragDrop to move any piece to any enabled square and I've regulated the sequence of moves (blue, red, blue etc) with a Static counter divided by
Mod 2 and a Source.BackColor test.
I need to limit the extent of any piece to one diagonally adjacent square in any direction. I have allocated the Index of each label in the control array as its Caption. My intention was to use two variables, NewLoc (for the destination square expressed in terms of a label Index) and OldLoc (for the vacated square again to be expressed in terms of a label index).
Newloc is easy to produce from the X and Y of Form_DragDrop, so I tried to create a function (GetOldLoc) to return the Caption of the vacated square, but because I am using Source + attributes the function will not return OldLoc as it needs a better identifier than Source. I would have used the test "If NewLoc - OldLoc is not equal to -9, -7, 7 0r 9 Then Exit Sub Else Source.Move X, Y etc."
I could write some 160 lines (32 squares times 5 pieces) in the function, but this would produce so much spaghetti.
Anybody suggest a function method to produce this OldLoc, please?