Nesler, Thomas J wrote:
How about this solution.  Use the Onchange Event to put this  code in:

procedure TForm1.Edit1Change(Sender: TObject);
begin
If Pos('.',Edit1.Text) > 0 then DotVar := True   //Global Var to check
for decimal point
                           else DotVar := False;
If DotVar = true then  {check  for more than one number past decimal
point}
If Length(Edit1.text) - Pos('.',Edit1.Text)> 1 then Begin
          Showmessage('Only one decimal point precision allowed');
        Edit1.text := Copy(edit1.text,1,Length(Edit1.text)-1);
        end;
end;

Be sure to create a global Boolean variable called DotVar to hold the
flag for checking the number of decimals.

Why do you need to global variable at all if you are setting its value every time you enter the Edit1Change method?

BTW, I would set it using a single line:
  DotVar := (Pos('.',Edit1.Text) > 0);
_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to