Необходимо добавить ограничение на ввод чисел больше 100
| Код | procedure Tnew_order.Edit2KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['0'..'9', DecimalSeparator,#8,#13]) or ((Key = DecimalSeparator) and (POS (DecimalSeparator, Edit2.Text) = 0)) or ((Key = '-') and (POS ('-', Edit2.Text) = 0)) then begin Key := #0; end; end;
|
Пробовал так
| Код | procedure Tnew_order.Edit2KeyPress(Sender: TObject; var Key: Char); var x:integer begin if not (Key in ['0'..'9', DecimalSeparator,#8,#13]) or ((Key = DecimalSeparator) and (POS (DecimalSeparator, Edit2.Text) = 0)) or ((Key = '-') and (POS ('-', Edit2.Text) = 0)) then begin Key := #0; end; x:=strtoint(edit2.Text); if (x < 0) or (x > 100) then begin key := #0; end; end;
|
Но ругается на любой ввод '''is not a valid integer value. |