谁帮我做一个模拟平抛运动的VB程序?
具体要求:结合物理学知识和TIMER控件,利用VB开发一个简易的模拟平抛运动(可以不考虑空气阻力的影响)的程序。大家尽快做嘛,可以发邮件,也可以写在回答里。谢谢了哈!!!...
具体要求:
结合物理学知识和TIMER控件,利用VB开发一个简易的模拟平抛运动(可以不考虑空气阻力的影响)的程序。
大家尽快做嘛,可以发邮件,也可以写在回答里。谢谢了哈!!!! 展开
结合物理学知识和TIMER控件,利用VB开发一个简易的模拟平抛运动(可以不考虑空气阻力的影响)的程序。
大家尽快做嘛,可以发邮件,也可以写在回答里。谢谢了哈!!!! 展开
2个回答
展开全部
给你写了一个,可以选择初速度,能显示当前垂直速度,水平距离,下降高度和经历时间的数值。需要添加一个文本框,两个按钮,11个标签(AutoSize属性设为True),两条直线,一个Timer控件(Interval属性设为10),一个Picture控件(代表平抛物体)。
你要程序文件的话留个QQ或邮箱,我给你发过去。
以下为程序:
Dim n%, t!, h!, v!
Const g = 9.8
Private Sub Command1_Click()
Command1.Caption = "开始"
Command1.Enabled = True
v = Text1 / 20
n = n + 1
If n Mod 2 <> 0 Then
Command1.Caption = "暂停"
Timer1.Enabled = True
Else
Command1.Caption = "继续"
Timer1.Enabled = False
Label2.Caption = Format(g * t, "0.00") & "m/s"
Label3.Caption = Format(h, "0.00") & "m"
Label4.Caption = Format(t * 20 * v, "0.00") & "m"
Label5.Caption = Format(t, "0.00") & "s"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Timer1_Timer()
t = t + 0.05
h = 0.5 * g * t ^ 2
Picture1.Left = Picture1.Left + 50 * v
Picture1.Top = Picture1.Top + h
If Picture1.Top > 5000 Or Picture1.Top = 5000 Then
Timer1.Enabled = False
Command1.Caption = "结束"
Command1.Enabled = False
Label2.Caption = Format(g * t, "0.00") & "m/s"
Label3.Caption = Format(h, "0.00") & "m"
Label4.Caption = Format(t * 20 * v, "0.00") & "m"
Label5.Caption = Format(t, "0.00") & "s"
End If
End Sub
你要程序文件的话留个QQ或邮箱,我给你发过去。
以下为程序:
Dim n%, t!, h!, v!
Const g = 9.8
Private Sub Command1_Click()
Command1.Caption = "开始"
Command1.Enabled = True
v = Text1 / 20
n = n + 1
If n Mod 2 <> 0 Then
Command1.Caption = "暂停"
Timer1.Enabled = True
Else
Command1.Caption = "继续"
Timer1.Enabled = False
Label2.Caption = Format(g * t, "0.00") & "m/s"
Label3.Caption = Format(h, "0.00") & "m"
Label4.Caption = Format(t * 20 * v, "0.00") & "m"
Label5.Caption = Format(t, "0.00") & "s"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Timer1_Timer()
t = t + 0.05
h = 0.5 * g * t ^ 2
Picture1.Left = Picture1.Left + 50 * v
Picture1.Top = Picture1.Top + h
If Picture1.Top > 5000 Or Picture1.Top = 5000 Then
Timer1.Enabled = False
Command1.Caption = "结束"
Command1.Enabled = False
Label2.Caption = Format(g * t, "0.00") & "m/s"
Label3.Caption = Format(h, "0.00") & "m"
Label4.Caption = Format(t * 20 * v, "0.00") & "m"
Label5.Caption = Format(t, "0.00") & "s"
End If
End Sub
展开全部
在窗体上,添加一个Shape控件,一个Timer控件,添加如下代码 :
Private Sub Form_Load()
Form1.AutoRedraw = True
Timer1.Interval = 10
Timer1.Enabled = True
Shape1.Shape = 3
Shape1.FillStyle = 0
Shape1.FillColor = vbRed
Shape1.Move 0, 0, 500, 500
Form1.WindowState = 2
End Sub
Private Sub Timer1_Timer()
'y=at^2
Static i As Long
i = i + 50
Shape1.Move i, (i ^ 2) / 5000
Line -(i, (i ^ 2) / 5000)
If i > Form1.ScaleWidth - Shape1.Width Or (i ^ 2) / 5000 > Form1.ScaleHeight - Shape1.Height Then Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Form1.AutoRedraw = True
Timer1.Interval = 10
Timer1.Enabled = True
Shape1.Shape = 3
Shape1.FillStyle = 0
Shape1.FillColor = vbRed
Shape1.Move 0, 0, 500, 500
Form1.WindowState = 2
End Sub
Private Sub Timer1_Timer()
'y=at^2
Static i As Long
i = i + 50
Shape1.Move i, (i ^ 2) / 5000
Line -(i, (i ^ 2) / 5000)
If i > Form1.ScaleWidth - Shape1.Width Or (i ^ 2) / 5000 > Form1.ScaleHeight - Shape1.Height Then Timer1.Enabled = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询