用VB怎么做单摆??急急急
来源:百度知道 编辑:UC知道 时间:2024/05/29 07:41:15
利用timer控件及三角函数等实现。谢谢拉
一个直线line1 一个图形 shape1 其中shape1.shape=3(circle)
让shape的中间再直线最下面。平行,一个command按钮和时间timer控件
command1.caption="开始" 还有一个label控件 下面是代码:
Dim l As Integer
Dim i As Integer
Dim k As Boolean
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Command1.Caption = "暂停"
Timer1.Enabled = True
Else
Command1.Caption = "开始"
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
k = True
Label1.Caption = ""
l = Sqr((Line1.X2 - Line1.X1) * (Line1.X2 - Line1.X1) + (Line1.Y2 - Line1.Y1) * (Line1.Y2 - Line1.Y1))
Label1.Caption = "直线长度为:" & l
End Sub
Private Sub Timer1_Timer()
Dim X2 As Integer
Dim Y2 As Integer
If k = True Then
Line1.X2 = Line1.X1 - Sin(i * 3.1415926 / 180) * l
Line1.Y2 = Line1.Y1 + Cos(i * 3.1415926 / 180) * l
i = i