I've always just used the free number edit controls from
http://bak-o-soft.dk/ Was easier than trying to trap everything for me.
Doug Chamberlin wrote:
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
--
Del Texley IS Administrator LIPA (541) 484-6430
This transmission (including any attachments) may contain confidential
information, privileged material (including material protected by the
solicitor-client or other applicable privileges), or constitute non-public
information. Any use of this information by anyone other than the intended
recipient is prohibited. If you have received this transmission in error,
please immediately reply to the sender and delete this information from your
system. Use, dissemination, distribution, or reproduction of this transmission
by unintended recipients is not authorized and may be unlawful.
_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi