绘制多条线 Dim blackPen As New Pen(Color.Red, 3) Dim hwnd As IntPtr = PictureBox1.Handle Dim myGraphics As Graphics myGraphics = Graphics.FromHwnd(hwnd) Dim x1 As Integer = 100 Dim x2 As Integer = 500 Dim y1 As Integer = 10 Dim y2 As Integer = y1 Dim i As Int16 = 10, bothgap As Int16 = 20 ' myGraphics.DrawLine(blackPen, x1, y1, x2, y2) For i = 1 To 10 myGraphics.DrawLine(blackPen, x1, y1 + i * bothgap, x2, y1 + i * bothgap) 'myGraphics.DrawLine(blackPen, x1, y1 + 2 * 20, x2, y1 + 2 * 20) 'myGraphics.DrawLine(blackPen, x1, y1 + 3 * 20, x2, y1 + 3 * 20) 下一个 x1 = 100 x2 = 100 y1 = 10 + bothgap y2 = 200 + bothgap / 2 blackPen = New Pen(Color.Blue,3) For i = 1 To 21 ' myGraphics.DrawLine(blackPen, x1, y1, x2, y2) myGraphics.DrawLine(blackPen, x1 + (i - 1) * bothgap, y1, x2 + (i - 1) * bothgap , y2) ' myGraphics.DrawLine(blackPen, x1 + 2 * bothgap, y1, x2 + 2 * bothgap, y2)