-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrmDeterminarNumeroUnit1.pas
97 lines (86 loc) · 2.45 KB
/
FrmDeterminarNumeroUnit1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
unit FrmDeterminarNumeroUnit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TFrmDeterminarNumero = class(TForm)
Label1: TLabel;
NumeroEdit: TEdit;
AgregarButton: TButton;
ListBoxGeneralNum: TListBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ListBoxPares: TListBox;
ListBoxImpares: TListBox;
ListBoxPositivos: TListBox;
ListBoxNegativos: TListBox;
ListBoxPrimos: TListBox;
Label7: TLabel;
NumerosAgregadosEdit: TEdit;
procedure AgregarButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmDeterminarNumero: TFrmDeterminarNumero;
implementation
{$R *.dfm}
procedure TFrmDeterminarNumero.AgregarButtonClick(Sender: TObject);
var num:Double;
var contador:Integer;
var tempNum:Integer;
begin
num := StrToFloat(NumeroEdit.Text);
if num = 0 then
begin
ShowMessage('Numero Neutro');
NumeroEdit.Text := '';
NumeroEdit.SetFocus;
end
else
begin
if (ListBoxGeneralNum.Items.Count < 50) then
begin
ListBoxGeneralNum.Items.Add(FloatToStr(num));
NumeroEdit.Text := '';
NumeroEdit.SetFocus;
end
else
begin
ShowMessage('Solo se aceptan 50 valores');
end;
ListBoxPares.Items.Clear;
ListBoxImpares.Items.Clear;
ListBoxPositivos.Items.Clear;
ListBoxNegativos.Items.Clear;
ListBoxPrimos.Items.Clear;
end;
for contador :=0 to ListBoxGeneralNum.Items.Count - 1 do
begin
tempNum := StrToInt(ListBoxGeneralNum.Items[contador]);
if ((tempNum mod 2) = 0) then
begin
ListBoxPares.Items.Add(FloatToStr(tempNum));
end
else
begin
ListBoxImpares.Items.Add(FloatToStr(tempNum))
end;
if tempNum > 0 then
begin
ListBoxPositivos.Items.Add(FloatToStr(tempNum));
end
else
begin
ListBoxNegativos.Items.Add(FloatToStr(tempNum));
end
end;
NumerosAgregadosEdit.Text := IntToStr(ListBoxGeneralNum.Items.Count)
end;
end.