Интернет-журнал 'Домашняя лаборатория', 2007 №3 - Вудворт
Шрифт:
Интервал:
Закладка:
Private Sub TextBox1_Change()
TextBox6.Text=TextBox1.Text
End Sub
����� ��� ������������ ��� ��������� ������ � ������ ���� ����� ���������� ��������� ������ � ���� ����������� ����������. ��������, ����� �� ��� ��������,�� ������ F5 (������ ��������� �� ����������) � ������ ����� � ������ ���� �����.
��������� � � ���� ����������� ���������� ���������� ��� �� �����! ������, ������� "Change" � ������ ��, ������� ��� ���� ������������ � ����� ���������, ����� ����� ������� ������ ����� ������ ������������� ��������� ������� ����������� ����������� ���������� � ���������� ��� � ������ �� ����������.
��, � ���� �� ��� ��� �� �������, �� �������� �� ���������� ��� ��������� ������� �� ����������� ������ ������ ������ ���� ������������ ���� ����� (��. �� ���.�4.3) � ��� ������� ��������� ����� �� ������������: �������� � ���������� ����� ������� �������, ����������� �����-���� �������� � ��������, ����� �� ��� ��������� ��� ����� ������ � ������ ���� �����.
�������� ����������� �������� ���������� � ����� ��� � ������ ���������� ��������� ���� ������� ������ ����������� ����� ������� ����� ������-���� ������� � ����� �� ���� �����, � ����� ��� �������� ������� �� ������ ���� �����. ������ ���� ���������� �������� ��� ������� �� ���� ����� �������������� ����������������, ������� ����� �������� ����������� ����������� ���������� � ��� ������� ������� � ��������� ������������-���������, � �� ������� ����������� ������� "Change" ����� ����� �� ��������.
��������� �� ���� VBA ������� ����������� ����������� ����������. ��-������, ��� �������� ����� ����� ������ ���� ���������. � VBA ���� ����������� ������� ��� �������� ����, �������� �� �� ��� ���� ������ ������� ����� � IsNumeric (�����, ��������, ����� �� �������� � ������� "�����" ������� �� VBA �� Microsoft Office 97 �� ������ "��������� ��������� �������� ��������", � � ������� VBA �� ����� ������� ������ ����� ������ � �� ���������� ������������ ������ ����). �� � ����������. ��, � ��� �������� ������� �� ���� �������� � ��������� ���� ����� ����� ���������� ������� "Val". ����, ��������� ����������, ����
IsNumeric(TextBox1.Text) = True And IsNumeric(TextBox2.Text) = True And IsNumeric(TextBox3.Text) = True And IsNumeric(TextBox4.Text) = True And IsNumeric (TextBox5. Text) = True And Not Val(TextBox4.Text) = 0 And Not Val(TextBox5.Text) = 0
� ���� ������ ����� ����������� ������� �� ������� ������-�����:
rez = ((Val(TextBox1.Text)^2) * Val(TextBox2.Text) * Val(TextBox3.Text))/(Val(TextBox4.Text) * Val(TextBox5.Text))
� ���������� ��� � ���� ������ ����������:
TextBox6.Text = Str$(rez)
������ ����� �������� ��������� ���������� ���������� � ������ �� �� ���� ������������ ������� "Change":
Private Sub TextBox1_Change()
Scet
End Sub
Private Sub TextBox2 Change()
Scet
End Sub
Private Sub TextBox3_Change()
Scet
End Sub
Private Sub TextBox4_Change()
Scet
End Sub
Private Sub TextBox5_Change()
Scet
End Sub
Private Sub Scet()
If IsNumeric(TextBox1.Text) = True And IsNumeric(TextBox2.Text) = True And IsNumeric(TextBox3.Text) = True And IsNumeric(TextBox4.Text) = True And IsNumeric (TextBox5. Text) = True And Not Val(TextBox4.Text) = 0 And Not Val(TextBox5.Text) = 0 Then
rez = ((Val(TextBox1.Text)^2) * Val(TextBox2.Text) * Val(TextBox3.Text)) / (Val(TextBox4.Text) * Val(TextBox5.Text))
TextBox6.Text = Str$(rez)
Else
TextBox6.Text = ""
End If
End Sub
� �������� ��������� ��� ����� ���������, �� ����� ��� ����������� � ���������� ��������. ��� ������ "������" ���������� ������� "Click" (�� ���� ������� �� ������) ����� � ����� �� ���������:
Private Sub CommandButton2_Click()
Unload Me
End Sub
�� � ��� ���� ��� ������ ������ � "�������� ��������� � ��������". � ����� ��� ������� � �������� �� ������ �������� ����������, � ����������� �����, ���������� ��� ���������, ��� � ��������� ���������! ��� ����� ������� ��������
Selection.Text = "��� ����������� ���� ����������� � " + TextBox1.Text + " ����� �� ���������� ������ " + TextBox4.Text + " ������, �������� " + TextBox3.Text + " ��. �� � �������� �������������� " + TextBox5.Text + " �� �� ���� �� " + TextBox2.Text + " ������ ���������" + TextBox6.Text + " ������� �������. "
��� ���������� ����� �� �������� ����� ����� � ������� �� �