Procedure which checks the number of eating properly entered in
edit box with a comma
Number in Edit fields - check :)
/*
Procedure which checks the number of eating properly entered in
edit box with a comma
Declaration in public
Provjeribroj Procedure (Sender: savings);
Call procedures for example Edit1 field
provjeribroj (Edit1);
*/
procedure TForm1.provjeribroj(Sender : TEdit);
Var i,br,st: integer;
s : String;
priv : String;
begin
br := 0;
st:= Sender.SelStart;
s := Sender.Text;
if copy(s,1,1) = DecimalSeparator then
begin
Sender.Text := copy(s,2,length(s)) ;
Sender.SelStart :=st;
exit;
end;
for i := 1 to length(s) do
begin
if s[i] in ['0'..'9',DecimalSeparator] then
begin
if (s[i] = DecimalSeparator) then
begin
br:=br+1;
end;
if not(( br>1) and (s[i] = DecimalSeparator)) then
begin
priv := priv + s[i];
end
else
st:=st-1;
end
else
begin
st:=st-1;
end
end;
Sender.Text := priv;
Sender.SelStart :=st;
end;
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.