Sub DdaLine(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Long) Dim dx As Integer Dim dy As Integer Dim x As Integer Dim y As Integer Dim p As Integer Dim const1 As Integer Dim const2 As Integer Dim inc As Integer Dim tmp As Integer dx = x2 - x1 dy = y2 - y1 If (dx * dy >= 0) Then inc = 1 Else inc = -1If (Abs(dx) > Abs(dy)) Then If (dx < 0) Then tmp = x1 x1 = x2 x2 = tmp tmp = y1 y1 = y2 y2 = tmp dx = -dx dy = -dy End If p = 2 * dy - dx const1 = 2 * dy const2 = 2 * (dy - dx) x = x1 y = y1 Me.PSet (x, y), c While (x < x2) x = x + 1 If (p < 0) Then p = p + const1 Else y = y + inc p = p + const2 End If Me.PSet (x, y), c Wend Else If (dy < 0) Then tmp = x1 x1 = x2 x2 = tmp tmp = y1 y1 = y2 y2 = tmp dx = -dx dy = -dy End If p = 2 * dy - dx const1 = 2 * dy const2 = 2 * (dy - dx) x = x1 y = y1Me.PSet (x, y), c While (y < y2) y = y + 1 If (p < 0) Then p = p + const1 Else x = x + inc p = p + const2 End If Me.PSet (x, y), c Wend End IfEnd If End Sub