Моделирование взлета ракеты - VB
Формулировка задачи:
Может у кого есть какие идеи или наработки, поделитесь пожалуйста) а то сам не пойму с чего начать
Решение задачи: «Моделирование взлета ракеты»
textual
Листинг программы
Option Explicit Dim mr, mt, rt, vp, im, xi, yi, ms, si, csp, cx, y0, sby, imt, fire As Integer ' я бы так не написал Dim star(8, 2) As Byte Dim cdir As String Private Sub aboutp_Click() Form1.Show vbModal End Sub Private Sub btRun_Click() If tbMt = 0 Then MsgBox "Empty": Exit Sub restart imgRocket.Visible = True imgFire.Visible = True mr = Val(tbMr.Text) mt = Val(tbMt.Text) rt = Val(tbRt.Text) im = Val(tbIm.Text) vp = mt / rt cx = 400 If vp > 400 Then csp = vp / 400 Else csp = 1 cx = vp End If ms = okrD(im * Log((mr + mt) / mr)) If ms > Picture1.Height Then sby = 1 Else sby = 0 End If tms.Text = ms tm1.Enabled = True btRun.Caption = "" btRun.Enabled = False btStop.Caption = "СТОП" btStop.Enabled = True cdir = CurDir imgFire.Visible = True tbIm.Enabled = False tbMr.Enabled = False tbMt.Enabled = False tbRt.Enabled = False End Sub Private Sub btStop_Click() restart End Sub Sub restart() xi = 0 yi = 0 imt = 0 ' Picture2.Line (0, 0)-(Picture2.Width, Picture2.Height), vbBlack, BF Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height), vbWhite, BF lbS.Caption = "0" lbS.Left = Picture1.Left - 100 lbS.Top = Picture1.Top + Picture1.Height + 5 lbT.Caption = "0" ' lbT.Left = lbS.Left lbT.Top = lbS.Top tm1.Enabled = False btRun.Caption = "ЗАПУСК" btRun.Enabled = True tm2.Enabled = False imgRocket.Top = 172 imgFire.Top = 258 imgFire.Visible = False imgConst.Top = 260 imgConst.Height = 30 st1.Top = 48 st2.Top = 168 st3.Top = 112 st4.Top = 136 st5.Top = 80 st6.Top = 88 st7.Top = 40 tbIm.Enabled = True tbMr.Enabled = True tbMt.Enabled = True tbRt.Enabled = True End Sub Private Sub exitp_Click() Unload Form1 End Sub Private Sub Command2_Click() End Sub Private Sub Form_Load() 'frmRocket.Caption = CurDir Picture1.DrawWidth = 2 End Sub Private Sub Picture1_Paint() Dim y As Integer DrawStyle = vbSolid Line (Picture1.Left - 5, Picture1.Top + Picture1.Height)-(Picture1.Left - 5, Picture1.Top - 15) Line (Picture1.Left - 5, Picture1.Top - 15)-(Picture1.Left - 10, Picture1.Top - 5) Line (Picture1.Left - 5, Picture1.Top - 15)-(Picture1.Left, Picture1.Top - 5) CurrentX = Picture1.Left - 40 CurrentY = Picture1.Top - 20 Print "u (м/с)" Line (Picture1.Left - 5, Picture1.Top + Picture1.Height + 3)-(Picture1.Left + Picture1.Width + 15 + 20, Picture1.Top + Picture1.Height + 3) Line (Picture1.Left + Picture1.Width + 5 + 20, Picture1.Top + Picture1.Height - 1)-(Picture1.Left + Picture1.Width + 15 + 20, Picture1.Top + Picture1.Height + 3) Line (Picture1.Left + Picture1.Width + 5 + 20, Picture1.Top + Picture1.Height + 8)-(Picture1.Left + Picture1.Width + 15 + 20, Picture1.Top + Picture1.Height + 3) CurrentX = Picture1.Left + Picture1.Width + 20 CurrentY = Picture1.Top + Picture1.Height + 5 Print "t (c)" lbT.Left = Picture1.Left - 10 lbT.Top = Picture1.Top + Picture1.Height + 5 'CurrentY = lbT.Top 'CurrentX = lbT.Left 'Print "0" End Sub Private Sub setval_Click() tbIm.Text = 4500 tbMr.Text = 4730 tbMt.Text = 28000 tbRt.Text = 5 End Sub Private Sub start_Click() btRun_Click End Sub Private Sub stop_Click() btStop_Click End Sub Private Sub Tm1_Timer() Dim yi As Integer xi = xi + 1 If xi <= cx Then si = im * Log((mr + mt) / (mr + mt - csp * rt * xi)) imt = mt - okrD(xi * csp * rt) tbMt.Text = imt lbT.Caption = xi * csp lbT.Left = Picture1.Left - ((lbT.Width) / 2) + xi If sby = 1 Then yi = okrD(si * Picture1.Height / ms) Else yi = okrD(si / 1) End If lbS.Caption = CStr(okrD(si / 1)) lbS.Left = Picture1.Left - 5 - lbS.Width lbS.Top = (Picture1.Top + Picture1.Height) - yi - lbS.Height / 2 Picture1.PSet (xi, Picture1.Height - yi), vbRed If fire <> 2 Then imgFire.Picture = Picture3.Picture fire = 2 Else imgFire.Picture = Picture4.Picture fire = 1 End If If si > 1 Then tm2.Interval = 500 - si * 500 / ms If tm2.Enabled = False Then tm2.Enabled = True End If End If End If End Sub Function setSec(mt, rt) Dim res As Integer res = mt / rt End Function Function okrD(dr As Double) As Long Dim c As Long c = Fix(dr) If dr = c Then okrD = c ElseIf (dr - c) > 0.5 Then okrD = c + 1 Else: okrD = c End If End Function Private Sub tm2_Timer() st1.Top = st1.Top + 1 st2.Top = st2.Top + 1 st3.Top = st3.Top + 1 st4.Top = st4.Top + 1 st5.Top = st5.Top + 1 st6.Top = st6.Top + 1 st7.Top = st7.Top + 1 If imgConst.Top < 291 Then imgConst.Top = imgConst.Top + 1 imgConst.Height = imgConst.Height - 1 End If imgRocket.Top = imgRocket.Top - 1 imgFire.Top = imgFire.Top - 1 End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д