VB设置坐标

来源:百度知道 编辑:UC知道 时间:2024/05/18 08:05:01
就是比如,我要在一个窗体移动鼠标到某个地方按“A”键,就能在此定义一个坐标点,显示在TEXT1里,然后移动鼠标到另一个地方,按下“S”键,就能定义另一个坐标点,显示在TEXT2里!
希望大家帮帮忙!有源码的最好
明天源码的希望给出关键的代码以及原理!

按你的意思写了个,只用了1个TEXT,你看看是不是你要的。。
Dim x1, y1
Private Sub Form_KeyPress(KeyAscii As Integer)
Text1.Text = Text1.Text & Chr(KeyAscii) & "键-坐标(x,y)(" & x1 & "," & y1 & ")" & vbCrLf
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X
y1 = Y
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub