Okay so im building a minesweeper game in Vb6. The main coding is pretty
\r\nstraightforward however im having trouble making the code behind the zeros buttons (the minespots that have no mines adjacent). I am using two main sub procedures that are recursing off of each other with functions just checking where the minespot is located. I am using a control array and a boolean array. It is a 10*20 grid
\r\ncode of trouble spot is as follows
\r\n
\r\n
\r\n
Code:
\r\n
Private Sub Determine(ByVal index As Integer)\r\n\'declare local variables\r\nDim intCount As Integer\r\n\r\n\'checks if mine swept is on a corner, side or in interior\r\nIf index = 0 Or index = 19 Or index = 180 Or index = 199 Then\r\n intCount = CornerMine(index)\r\nElseIf isSideMine(index) = "right side" Then \'checks if its on side but not corner\r\n intCount = RightMine(index)\r\nElseIf isSideMine(index) = "left side" Then\r\n intCount = LeftMine(index)\r\nElseIf isTopBottom(index) = "top" Then \'sends to appropriate function if on top of mine section\r\n intCount = TopMine(index)\r\nElseIf isTopBottom(index) = "bottom" Then \' sends to appropriate function if on top of mine section\r\n intCount = BottomMine(index)\r\nElse\r\n intCount = Interior(index) \'then button clicked is indeed in the interior\r\nEnd If\r\n \r\n \'if zero\r\nIf intCount = 0 Then\r\n \'complex looping structure with the determine sub procedure that allows indexs adjacent to the zero to be id\'d.\r\n\'disable zero\r\ncmdSpot(index).Enabled = False\r\ncmdSpot(index).Caption = "0"\r\n\'disable or display captions of minespots adjacent to zero\r\nIf index = 0 Then\r\n Call Determine(index + 1)\r\n Call Determine(index + 21)\r\n Call Determine(index + 20)\r\nElseIf index = 19 Then\r\n Call Determine(index + 20)\r\n Call Determine(index + 19)\r\n Call Determine(index - 1)\r\nElseIf index = 180 Then\r\n Call Determine(index + 1)\r\n Call Determine(index - 20)\r\n Call Determine(index - 19)\r\nElseIf index = 199 Then\r\n Call Determine(index - 1)\r\n Call Determine(index - 20)\r\n Call Determine(index - 21)\r\nElseIf isTopBottom(index) = "top" Then\r\n Call Determine(index + 19)\r\n Call Determine(index + 20)\r\n Call Determine(index + 21)\r\n Call Determine(index + 1)\r\n Call Determine(index - 1)\r\nElseIf isTopBottom(index) = "bottom" Then\r\n Call Determine(index - 19)\r\n Call Determine(index - 20)\r\n Call Determine(index - 21)\r\n Call Determine(index - 1)\r\n Call Determine(index + 1)\r\nElseIf isSideMine(index) = "right side" Then \'check if on far left or far right row\r\n Call Determine(index - 20)\r\n Call Determine(inex - 21)\r\n Call Determine(index - 1)\r\n Call Determine(index + 19)\r\n Call Determine(index + 20)\r\nElseIf isSideMine(index) = "left side" Then\r\n Call Determine(index - 20)\r\n Call Determine(index - 19)\r\n Call Determine(index + 1)\r\n Call Determine(index + 20)\r\n Call Determine(index + 21)\r\nElse \'means it is interior spot\r\n Call Determine(index + 19)\r\n Call Determine(index + 20)\r\n Call Determine(index + 21)\r\n Call Determine(index + 1)\r\n Call Determine(index - 1)\r\n Call Determine(index - 19)\r\n Call Determine(index - 20)\r\n Call Determine(index - 21)\r\nEnd If\r\nElse\r\n \'determine what caption to display\r\n cmdSpot(index).Caption = intCount\r\nEnd If\r\n\r\n \r\n\r\nEnd Sub
\r\n
the functions not displayed are pretty self explanatory i think. this is the problem ive been getting. I might be doing this all wrong as i taught myself recursion, so any thoughts or debugging tips are appreciated.
\r\n \r\n\r\n