Jump to content

Recommended Posts

Posted
Hello everyone!

I'm trying to use the keyPress DBEdit, but is not working.

In a DBEdit, I have to create a formula (using parser.pas), but want the user to only enter numbers and some specific letters, the formula.

I tried to do the following below, but is not working.

 


procedure TForm.UniDBEdit1KeyPress(Sender: TObject; var Key: Char);

begin                            //                    +     -    *    /    ^    [    ]    (    )

   if not (Key in ['0'..'9','Q','P','V', 'L','D', 'M', #43, #45, #42, #47, #94,#91, #93, #40, #41, #8]) then begin

      key := 0; <-- error char vs string

      //Key := chr('0'); <-- dont work

   end;

end;


 

When the letter that is not present in the function, it is accept by the procedure and allows inclusion in Edit.

Can anyone help?

Thanks.

 

 

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...