Procedure AllowInputNumber(obj: tobject
Var key: char);
Var
text: String;
SelStart, SelLength: integer;
Begin
SelStart := (obj As tdbedit).SelStart;
SelLength := (obj As tdbedit).SelLength;
//如果输入其他字符,不响应
If Not (key In ['0'..'9', '.', #8]) Then
Key := #0;
text := (obj As tdbedit).text;
If (Key = '.') Then Begin
If (Pos('.', Text) > 0) And ((SelLength = 0) Or (Not ((SelStart < Pos('.', Text)) And (SelLength >= Pos('.', Text) - SelStart)))) Then
Key := #0
//不出现两个小数点[/red]
If SelStart = 0 Then //小数点不出现在第一位
Key := #0;
End;
End;