求一个简单的Visual Basic程序~~
在窗体上画一个picture,把picturescale(0,0)-(20,20)在TexT里输入一个坐标值,在picturebox显示这个点...(以上我都会做)接下来...
在窗体上画一个picture, 把picture scale (0,0)-(20,20)
在TexT里输入一个坐标值,在picturebox显示这个点...(以上我都会做)
接下来的问题是:在TEXT再输入一个点,单击command1,使这个点和前一个点连成一条线,如此类推,继续连线......
我自己编了一个,
Dim n As Integer
Dim m(25) As Single
Dim k(25) As Single
Private Sub Command1_Click()
n = n + 1
a = Text1.Text
b = Text2.Text
m(n) = a
k(n) = b
Picture1.Circle (a, b), 0.2
End Sub
Private Sub Command2_Click()
Picture1.Line (m(n), k(n))-(m(n - 1), k(n - 1))
Print m(n), k(n)
Print m(n + 1), k(n + 1)
End Sub
Private Sub Form_Load()
n = 0
Picture1.Scale (0, 20)-(20, 0)
End Sub
只不过TexT1\2里分别输入X\Y值~ 展开
在TexT里输入一个坐标值,在picturebox显示这个点...(以上我都会做)
接下来的问题是:在TEXT再输入一个点,单击command1,使这个点和前一个点连成一条线,如此类推,继续连线......
我自己编了一个,
Dim n As Integer
Dim m(25) As Single
Dim k(25) As Single
Private Sub Command1_Click()
n = n + 1
a = Text1.Text
b = Text2.Text
m(n) = a
k(n) = b
Picture1.Circle (a, b), 0.2
End Sub
Private Sub Command2_Click()
Picture1.Line (m(n), k(n))-(m(n - 1), k(n - 1))
Print m(n), k(n)
Print m(n + 1), k(n + 1)
End Sub
Private Sub Form_Load()
n = 0
Picture1.Scale (0, 20)-(20, 0)
End Sub
只不过TexT1\2里分别输入X\Y值~ 展开
展开全部
Dim point_currentX, point_currentY '当前坐标
Dim point_recentX, point_recentY '前一点坐标
Dim isfirstpoint As Boolean '判断是否为第一点
Private Sub Form_Load()
isfirstpoint = True
End Sub
'获取当前鼠标点击的X,Y的坐标
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
point_currentX = X
point_currentY = Y
PSet (X, Y)
End Sub
Private Sub Command1_Click()
If isfirstpoint = True Then '把(0,0)改为你自己要求的第一点坐标即可
Picture1.Line (0, 0)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
isfirstpoint = False
Else '用直线连接前一点与当前点
Picture1.Line (point_recentX, point_recentY)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
End If
End Sub
Dim point_recentX, point_recentY '前一点坐标
Dim isfirstpoint As Boolean '判断是否为第一点
Private Sub Form_Load()
isfirstpoint = True
End Sub
'获取当前鼠标点击的X,Y的坐标
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
point_currentX = X
point_currentY = Y
PSet (X, Y)
End Sub
Private Sub Command1_Click()
If isfirstpoint = True Then '把(0,0)改为你自己要求的第一点坐标即可
Picture1.Line (0, 0)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
isfirstpoint = False
Else '用直线连接前一点与当前点
Picture1.Line (point_recentX, point_recentY)-(point_currentX, point_currentY)
point_recentX = point_currentX
point_recentY = point_currentY
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询