Jump to content
Ian Branch

allow cut & paste of numbers only..

Recommended Posts

Hi Team,

ATT I use this routine in the OnKeyPress of the TDBEdit to limit the data entry to only numbers.

  // #8 is Backspace
  if not (Key in [#8, '0'..'9']) then begin
    MessageBeep(MB_ICONERROR);
    TaskMessageDlg('Invalid data entry!', 'Only numbers are allowed for the Service #.', mtError, [mbOK], 0);
    // Discard the key
    Key := #0;
  end;
  //

Unfortunately this does not allow cut & paste of a number.

How can I facilitate cut & paste a number with leading or trailing spaces, without losing the numeric control?

I have tried using MaskEdit but it still allows the pasting of the number with leading or trailing spaces. :-(

Regards & TIA,

Ian

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×