首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

新手问:怎么获得鼠标多次点击点的坐标

2012-03-04 
新手问:如何获得鼠标多次点击点的坐标?我在picturebox里的一幅图像上,用鼠标在不同位置上先后点三个点,如

新手问:如何获得鼠标多次点击点的坐标?
我在picturebox里的一幅图像上,用鼠标在不同位置上先后点三个点,如何可以获得这三个点的坐标值呢,比如输出到label里显示出来

[解决办法]
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "x= " & X & " y= " & Y
End Sub

[解决办法]
你用这个,不管你点多少下 都可以显示出你的坐标
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = Label1.Caption & X & " " & Y & ", "
End Sub

[解决办法]
我来代码实现......:)

定义一个公有数组,然后在点击事件里记录

dim PTArrX() as long,PTArrY() as long '在窗体公共声明部分

private sub form_load()
redim ptarrx(0):redim ptarry(0)
end sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
dim tmpI as long

tmpi = ubound(ptarrx)+1

redim preserve ptarrx(tmpi)
redim preserve ptarry(tmpi)

ptarrx(tmpi)=x:ptarry(tmpi)=y
Label1.Caption = Label1.Caption & X & " " & Y & ", "
End Sub

热点排行