-
Notifications
You must be signed in to change notification settings - Fork 0
/
UMassa.pas
executable file
·79 lines (64 loc) · 1.5 KB
/
UMassa.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
unit UMassa;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
UEmbedForm, StdCtrls,
tc;
type
TFMassa = class(TEmbedForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
public
function GetNumber : massa;
procedure SetNumber(value : massa);
property Number : massa read GetNumber write SetNumber;
end;
implementation
{$R *.DFM}
{ TFMassa }
function TFMassa.GetNumber: massa;
begin
try
result := StrToFloat(Edit1.Text);
except
Number := 0;
result := 0;
end;
end;
procedure TFMassa.SetNumber(value: massa);
begin
if Value >= 0 then
Edit1.Text := FloatToStr(value);
end;
procedure TFMassa.FormCreate(Sender: TObject);
begin
inherited;
Number := 1000;
end;
procedure TFMassa.Button1Click(Sender: TObject);
begin
Number := Number * 1000;
Edit1.SetFocus;
end;
procedure TFMassa.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not(
(Key in ['0'..'9']) or
(key = #8) or
(key = ',')
) then
key := #27;
end;
procedure TFMassa.Edit1Change(Sender: TObject);
begin
Label2.Caption := format('%.2f', [Number / 1000]);
end;
end.