Below code shows that I have a For...Next loop checking 4 possibilities and for each one that is true I have the same code execution except for the value in DropCount. I set it up as a GoSub so I wouldn't have to duplicate the code for each If...End If clause. However, I have read that using GoSub is not the best practice to use so is there another and better way?
Code:
Private Sub ShowBallsOnGameBoard()
Dim PosY As Long
Dim CellNumber As Integer
Dim DropCount As Integer
Dim n1 As INteger
For n1 = 1 To 16
If Pole(n1).FourthFromTop <> 0 Then
DropCount = 1: GoSub PutBallOnBoard
End If
If Pole(n1).ThirdFromTop <> 0 Then
DropCount = 2: GoSub PutBallOnBoard
End If
If Pole(n1).SecondFromTop <> 0 Then
DropCount = 3: GoSub PutBallOnBoard
End If
If Pole(n1).TopBall <> 0 Then
DropCount = 4: GoSub PutBallOnBoard
End If
Next n1
Exit Sub
PutBallOnBoard:
CellNumber = Pole(n1).CellNumber(DropCount)
PosY = Ball(Pole(n1).CellNumber(DropCount)).Y
picBallFromArray.Picture = PoleBalls(Ball(n1 - 1).ThisBall).GraphicCell(CellNumber)
TransparentBlt picGameBoard.hdc, Pole(n1).BallX, PosY, picBallFromArray.ScaleWidth, picBallFromArray.ScaleHeight, picBallFromArray.hdc, 0, 0, picBallFromArray.ScaleWidth, picBallFromArray.ScaleHeight, RGB(252, 4, 4)
picGameBoard.Refresh
Return
End Sub