你应该将多点座标的X及Y值赋值给变量X及Y的数组,然后使用 Option Explicit Dim x(500) As Single Dim y(500) As Single Dim i As Integer Private Sub Command1_Click() For i = 0 To 500 Picture1.PSet (x(i), y(i)) Next End Sub
给你写个代码,自己研究研究: Dim x1 As Integer Dim y1 As Integer Dim IsStart As BooleanPrivate Sub Form_Load() IsStart = False End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then IsStart = True x1 = X y1 = Y End If End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If IsStart = True And Button = 1 Then Form1.Cls Form1.Line (x1, y1)-(X, Y) End If End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Form1.Line (x1, y1)-(X, Y) IsStart = False End If End Sub
VB6示例代码: Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long Private Type POINTAPI x As Long y As Long End TypeDim pts(1 To 4) As POINTAPIPrivate Sub Form_Load() Me.AutoRedraw = True Me.ScaleMode = vbPixels '以下是随便写的点的坐标 pts(1).x = 10 pts(1).y = 10
pts(2).x = 20 pts(2).y = 20
pts(3).x = 10 pts(3).y = 20
pts(4).x = 40 pts(4).y = 50 '将点连接起来 Polyline Me.hdc, pts(1), 4 End Sub
Private Declare Function PolyBezier Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
picture1.PSet (x, y), vbRed '用红色绘点
我认为用picture1.line比较好,pset只能绘出离散的点。
Option Explicit
Dim x(500) As Single
Dim y(500) As Single
Dim i As Integer
Private Sub Command1_Click()
For i = 0 To 500
Picture1.PSet (x(i), y(i))
Next
End Sub
http://topic.csdn.net/u/20080515/09/f47e3407-7944-4cf5-9179-6722a02ffa8e.html
Dim x1 As Integer
Dim y1 As Integer
Dim IsStart As BooleanPrivate Sub Form_Load()
IsStart = False
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
IsStart = True
x1 = X
y1 = Y
End If
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If IsStart = True And Button = 1 Then
Form1.Cls
Form1.Line (x1, y1)-(X, Y)
End If
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Form1.Line (x1, y1)-(X, Y)
IsStart = False
End If
End Sub
Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End TypeDim pts(1 To 4) As POINTAPIPrivate Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
'以下是随便写的点的坐标
pts(1).x = 10
pts(1).y = 10
pts(2).x = 20
pts(2).y = 20
pts(3).x = 10
pts(3).y = 20
pts(4).x = 40
pts(4).y = 50
'将点连接起来
Polyline Me.hdc, pts(1), 4
End Sub