vb中图形的移动
来源:百度知道 编辑:UC知道 时间:2024/06/01 01:46:17
图形是通过描点绘出来的,不是loadpicture得到的!
在窗体上添加控件:VScroll1
Private Sub Form_Load()
'建立坐标系统
Dim x As Single, y As Single
Me.ScaleMode = 3
x = 10: y = x * Me.ScaleHeight / Me.ScaleWidth
Me.Scale (-x, -y)-(x, y)
Me.AutoRedraw = True
VScroll1.Min = -10
VScroll1.Max = 10
Call DrawPic(VScroll1.Value)
End Sub
Private Sub VScroll1_Change()
Call DrawPic(VScroll1.Value)
End Sub
Private Sub VScroll1_Scroll()
Call DrawPic(VScroll1.Value)
Me.Refresh
End Sub
Private Sub DrawPic(ByVal y0 As Single)
Dim P As Single, x As Single, y As Single
Dim i As Single, a As Single, b As Single
a = 5 'x 方向的半轴
b = 3 'y 方向的半轴
P = 3.1415926
Me.Cls
'画第一个点
i = 0: x = a * Sin(i): y = y0 + b * Cos(i)
Me.PSet (x, y)
'画中间点