There are several issues. First, the coordinates for board start at , not , so you are not processing the top row or the left column. Similarly, by checking
<=d, you're looking at invalid array locations off the right side of the board or below the bottom row when line or column actually equals d. Remember, an array with n elements in a dimension runs from 0 to n-1, not 1 to n.
After that, both checks in the final if statement are bad. counter can max out at (d*d)-1 and the limits on the board array are both d-1, not d. There may be other issues, but these are significant enough.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)