Private Sub CommandButton1_Click() Dim A(20), Sum As Integer Sum = 0 For i = 1 To 20 A(i) = Int(Rnd * 20) If A(i) > 3 Then Sum = Sum + A(i) TextBox1.Text = TextBox1.Text & A(i) & " " TextBox2.Text = Sum Next i If TextBox1.Text <> "" Then CommandButton1.Enabled = False CommandButton2.Enabled = True End If End Sub
Private Sub CommandButton2_Click() If TextBox1.Text <> "" Then CommandButton1.Enabled = True TextBox1.Text = "" TextBox2.Text = "" CommandButton2.Enabled = False End Sub
var
Ch, Mes, MaxCh: Integer;
begin
Write ('Введите число (1-31):');
ReadLn (Ch);
if (Ch < 1) or (Ch > 31) then begin
WriteLn ('Введено некорректное число');
Exit;
end;
Write ('Введите месяц (1-12): ');
ReadLn (Mes);
if (Mes < 1) or (Mes > 12) then begin
WriteLn ('Введен некорректный месяц');
Exit;
end;
case Mes of
1, 3, 5, 7, 8, 10, 12: MaxCh := 31;
4, 6, 9, 11: MaxCh := 30;
2: MaxCh := 28;
end;
if Ch <= MaxCh then
WriteLn ('Дата правильная')
else
WriteLn ('Дата неправильная!');
end.
// в программе не учитывается то, что в високосном году февраль имеет 29 дней
Dim A(20), Sum As Integer
Sum = 0
For i = 1 To 20
A(i) = Int(Rnd * 20)
If A(i) > 3 Then Sum = Sum + A(i)
TextBox1.Text = TextBox1.Text & A(i) & " "
TextBox2.Text = Sum Next i
If TextBox1.Text <> "" Then
CommandButton1.Enabled = False
CommandButton2.Enabled = True
End If
End Sub
Private Sub CommandButton2_Click()
If TextBox1.Text <> "" Then CommandButton1.Enabled = True
TextBox1.Text = ""
TextBox2.Text = ""
CommandButton2.Enabled = False
End Sub