Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi Ascii code

Posted on 2013-05-27
2
Medium Priority
?
1,134 Views
Last Modified: 2013-05-28
Hi All:
i've an edit box this edit box for numeric values. i'd like to make this edit box accept just numeric values i wrote on key press  the following

         IF NOT((Key IN ['0' .. '9']) OR (Key = #8) OR (Key = #17)OR (Key = #67)OR (Key = #86) OR (Key = #118)OR (Key = #88)OR (Key = #13)) THEN
                Key := #0;

but this code stop the ctrl+v, ctrl+c and ctrl+x

can you please help me to fix this issue and lets the edit box accept (ctrl+v).
0
Comment
Question by:khaled salem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 39199906
Here it is:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0' .. '9', #8, #13]) then
  begin
    //is it ctrl+..
    if HiWord(GetKeyState(VK_CONTROL)) <> 0 then //ctrl down
    begin
      if not (Key in [#3, #22, #24]) then Key := #0; //#3 = CTRL+C, #22 = CTRL+V, #24 = CTRL+X, 
    end
    else
      Key := #0;
  end;
end;

Open in new window

... for comma if number is decimal ... first line should be
if not (Key in ['0' .. '9', #8, #13, #44]) then...

Open in new window


...on torry.net you have lots of numeric edit components already
0
 

Author Closing Comment

by:khaled salem
ID: 39203065
Thanks alot
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question