用VB画一个Sin 0度到360度的函数图像,然后当鼠标放在图像上时,下面显示当前坐标

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:29:33

Rem 窗体上准备两个控件,Picture1和Label1

Const PI = 3.14159

Private Sub Form_Activate()
Picture1.AutoRedraw = True
Picture1.ScaleWidth = 16
Picture1.ScaleHeight = 2
xlen = Picture1.ScaleWidth / 2
ylen = Picture1.ScaleHeight / 2
Picture1.Scale (-xlen, ylen)-(xlen, -ylen)
Picture1.Line (-xlen, 0)-(xlen, 0) ' X轴
Picture1.Line (0, -ylen)-(0, ylen) ' Y轴
Rem 以上代码是初始化坐标系

Label1.Caption = "坐标:"
n = 0.01
For X = 0 To 2 * PI-n Step n
Picture1.Line (X, Sin(X))-(X + n, Sin(X + n))
Next X

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "坐标:x=" & Format(X, "0.000") & ",y=" & Format(Y, "0.000")
End Sub

- -||你到底想问些什么?

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim X1 As Single, Y1 As Singl