Занятие 32. Практическая работа 10.
Вариант решения.
Интерфейс проекта
Блок - схема 1 проекта
Программный код
Public h1 As Single
Public h2 As Single
Public p As Single
Public t As Byte
Private Sub Button1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button 1.Click
Dim n As Byte
n = Val(TextBox5.Text)
h1 = Val(TextBox1.Text)
p = Val(TextBox2.Text)
For t = 1 To n
h2 = h1 + (h1 * p) / 100
h1 = h2
ListBox1.Items.Add("t= " & t vbTab & vbTab & "h= " & Format(h1, "00.###"))
Next t
TextBox4.Text = Str(h2)
End Sub
Блок - схема 2 проекта
Программный код
Private Sub Button2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button2.Click
Dim k As Single
h1 = Val(TextBox1.Text)
p = Val(TextBox2.Text)
k = Val(TextBox3.Text)
t = 0
Do
h2 = h1 + (h1 * p) / 100
h1 = h2
t = t + 1
Loop While h1 < k 'если условие true - цикл повторяется
TextBox6.Text = Str(t)
End Sub
Private Sub Button3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button3.Click
TextBox4.Text = ""
TextBox6.Text = ""
TextBox5.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.Text = ""
ListBox1.Items.Clear()
TextBox1.Focus()
End Sub