MaskEdit for Numbers

I was looking at replacing some specialized components with a MaskEdit 
component in several forms in my application. Some changes have been 
made to MaskEdit that were way too long in coming, and I gave it a try.
What I found was that the masks are woefully inadequate for handling 
numbers. (I'd say maybe it was me, but I spent a lot of time trying to 
find something that works).

What I want: For a mixed number, I want the user to be able to tab into 
the component, type "1.25" and tab to the next field. And I want the 
component to be able to handle other numbers - not a mask that only 
works for this size number.

So what's wrong? The mask wants to indicate where characters can be 
typed, so only this field has underscores. If I allow 3 integer digits, 
the typed "1" goes into the first position, then jumps over 2 to the 
decimal where the "25" is entered (correctly). I'd like to be able to 
initialize the field with, maybe "0.00". Nothing works smoothly enough. 
If only I wanted to enter a telephone number. Am I lost here or is there 
some mask that will allow the user to enter numbers easily?
0
Patrick
2/28/2012 12:33:43 AM
embarcadero.delphi.ide 3925 articles. 0 followers. Follow

10 Replies
11332 Views

Similar Articles

[PageSpeed] 43

Patrick Moloney wrote:

> I was looking at replacing some specialized components with a MaskEdit 
> component in several forms in my application. Some changes have been 
> made to MaskEdit that were way too long in coming, and I gave it a try.
> What I found was that the masks are woefully inadequate for handling 
> numbers. (I'd say maybe it was me, but I spent a lot of time trying to 
> find something that works).
> 
> What I want: For a mixed number, I want the user to be able to tab into 
> the component, type "1.25" and tab to the next field. And I want the 
> component to be able to handle other numbers - not a mask that only 
> works for this size number.
> 
> So what's wrong? The mask wants to indicate where characters can be 
> typed, so only this field has underscores. If I allow 3 integer digits, 
> the typed "1" goes into the first position, then jumps over 2 to the 
> decimal where the "25" is entered (correctly). I'd like to be able to 
> initialize the field with, maybe "0.00". Nothing works smoothly enough. 
> If only I wanted to enter a telephone number. Am I lost here or is there 
> some mask that will allow the user to enter numbers easily?

Take a look in help for TEditMask.
There's a list of the characters to use for different masks, the ones you might be interested in
are:
0  The 0 character requires a numeric character only in this position.  
9  The 9 character permits a numeric character in this position, but doesn't require it.  
#  The # character permits a numeric character or a plus or minus sign in this position, but
doesn't require it.

So, maybe something like  '#99999990.00;0;_' as the value for the TMaskEdit.EditMask property does
what you are after.

Cheers
Tom

-- 
Tom Brunberg
firstname.surname@welho.com
1
Tom
2/28/2012 7:04:04 AM
Or just use a normal TEdit and check the "NumbersOnly" property.  Much 
simpler than trying to use MaskEdit.


"Tom Brunberg"  wrote in message news:449004@forums.embarcadero.com...

Patrick Moloney wrote:

> I was looking at replacing some specialized components with a MaskEdit
> component in several forms in my application. Some changes have been
> made to MaskEdit that were way too long in coming, and I gave it a try.
> What I found was that the masks are woefully inadequate for handling
> numbers. (I'd say maybe it was me, but I spent a lot of time trying to
> find something that works).
>
> What I want: For a mixed number, I want the user to be able to tab into
> the component, type "1.25" and tab to the next field. And I want the
> component to be able to handle other numbers - not a mask that only
> works for this size number.
>
> So what's wrong? The mask wants to indicate where characters can be
> typed, so only this field has underscores. If I allow 3 integer digits,
> the typed "1" goes into the first position, then jumps over 2 to the
> decimal where the "25" is entered (correctly). I'd like to be able to
> initialize the field with, maybe "0.00". Nothing works smoothly enough.
> If only I wanted to enter a telephone number. Am I lost here or is there
> some mask that will allow the user to enter numbers easily?

Take a look in help for TEditMask.
There's a list of the characters to use for different masks, the ones you 
might be interested in
are:
0  The 0 character requires a numeric character only in this position.
9  The 9 character permits a numeric character in this position, but doesn't 
require it.
#  The # character permits a numeric character or a plus or minus sign in 
this position, but
doesn't require it.

So, maybe something like  '#99999990.00;0;_' as the value for the 
TMaskEdit.EditMask property does
what you are after.

Cheers
Tom

-- 
Tom Brunberg
firstname.surname@welho.com
0
John
2/28/2012 12:46:43 PM
On 2/28/2012 7:46 AM, John Friel III wrote:
> Or just use a normal TEdit and check the "NumbersOnly" property.  Much
> simpler than trying to use MaskEdit.
>

It is simpler.
-1
Patrick
2/28/2012 12:59:06 PM
On 2/28/2012 2:04 AM, Tom Brunberg wrote:
>
> Take a look in help for TEditMask.
> There's a list of the characters to use for different masks, the ones you might be interested in
> are:
> 0  The 0 character requires a numeric character only in this position.
> 9  The 9 character permits a numeric character in this position, but doesn't require it.
> #  The # character permits a numeric character or a plus or minus sign in this position, but
> doesn't require it.
>
> So, maybe something like  '#99999990.00;0;_' as the value for the TMaskEdit.EditMask property does
> what you are after.
>
> Cheers
> Tom
>

I tried everything I could think of with that EditMask yesterday. The 
user gets "1", then six spaces, then ".25".  Doesn't look anything like 
a number. Asking the user to move character by character with the arrow 
key is just unacceptable.

I think they beefed up the documentation on this since the original 
release of IB. I even put in a QC entry that MaskEdit was poorly 
documented. So its here, but the writer added no insight into how it 
works, and the description is minimal. In fairness there, if the 
developer provided better documentation of what he had created, maybe he 
would have seen the difficulty in working with numbers. (Or maybe that 
wasn't even what he wanted.)
0
Patrick
2/28/2012 1:08:39 PM
"John Friel III" <john@frieltek.com> wrote in message 
news:449065@forums.embarcadero.com...
> Or just use a normal TEdit and check the "NumbersOnly" property.  Much
> simpler than trying to use MaskEdit.


Unfortunately that only works for integer fields - doesn't allow decimal.

For decimal values one can also use OnKeyPress. I normally create one of 
these per form and assign all appropriate controls to use that.

  if not (Key in [#1..#31, "0".."9", '.']) then
    Key := #0;

-- 
Wayne Niddery (TeamB)
"'Thank you, Occupy Wall Street. With your vivid example of anticapitalist 
squalor, I've been able to convince all three of my children to become 
investment bankers"  - P. J. O’Rourke
0
Wayne
2/28/2012 1:12:54 PM
On 2/28/2012 8:12 AM, Wayne Niddery wrote:
> "John Friel III"<john@frieltek.com>  wrote in message
> news:449065@forums.embarcadero.com...
>> Or just use a normal TEdit and check the "NumbersOnly" property.  Much
>> simpler than trying to use MaskEdit.
>
>
> Unfortunately that only works for integer fields - doesn't allow decimal.
>
> For decimal values one can also use OnKeyPress. I normally create one of
> these per form and assign all appropriate controls to use that.
>
>    if not (Key in [#1..#31, "0".."9", '.']) then
>      Key := #0;
>

Oh yeah, there was that problem too. I tried that.
I was considering, rather than OnKeyPress, to just check the value when 
the user submits the form. Workable.
I was also trying to get some standard method to display data that is 
retrieved. Some data is not just dollars and cents, but various levels 
of decimals and/or integers. Simply tweaking a mask on a form would be 
nice, but I don't think Delphi can do that.

I'm using PBEditPack for number entry, which works pretty well. But it's 
just one more separate piece I would replace with standard components if 
I could. It looks like it's still giving me something I can't get standard.
0
Patrick
2/28/2012 1:38:20 PM
Patrick Moloney wrote:

> I tried everything I could think of with that EditMask yesterday. The 
> user gets "1", then six spaces, then ".25".  Doesn't look anything
> like a number. Asking the user to move character by character with
> the arrow key is just unacceptable.

The control is simply not suitable and also not intended for the
purpose you are trying to use it for. It was designed for things like
phone numbers or area codes, where you have a fixed number of digits.



-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://codenewsfast.com
http://groups.google.com
0
Peter
2/28/2012 8:20:55 PM
Patrick Moloney wrote:

> On 2/28/2012 2:04 AM, Tom Brunberg wrote:
> > 
> > Take a look in help for TEditMask.
> > There's a list of the characters to use for different masks, the ones you might be interested in
> > are:
> > 0  The 0 character requires a numeric character only in this position.
> > 9  The 9 character permits a numeric character in this position, but doesn't require it.
> > #  The # character permits a numeric character or a plus or minus sign in this position, but
> > doesn't require it.
> > 
> > So, maybe something like  '#99999990.00;0;_' as the value for the TMaskEdit.EditMask property
> > does what you are after.
> > 
> > Cheers
> > Tom
> > 
> 
> I tried everything I could think of with that EditMask yesterday. The 
> user gets "1", then six spaces, then ".25".  Doesn't look anything like 
> a number. Asking the user to move character by character with the arrow 
> key is just unacceptable.
> 
> I think they beefed up the documentation on this since the original 
> release of IB. I even put in a QC entry that MaskEdit was poorly 
> documented. So its here, but the writer added no insight into how it 
> works, and the description is minimal. In fairness there, if the 
> developer provided better documentation of what he had created, maybe he 
> would have seen the difficulty in working with numbers. (Or maybe that 
> wasn't even what he wanted.)

Ok, then I would suggest to use a TEdit and validate the entry in the OnExit event. If wrong, use
SetFocus to set the focus back to the Edit control.

Cheers
Tom

-- 
Tom Brunberg
firstname.surname@welho.com
0
Tom
2/28/2012 8:50:05 PM
That is the conclusion I came to. After failing to find a solution in testing I posted here in case I was missing something.
Thanks.
0
Patrick
2/29/2012 2:05:30 PM
Well it is either TEdit or the 3rd Party component I currently use. 

This search was triggered by one form that had a TEdit and looked bad compared to the usual 3rd Party component. I was going to "Fix" it, but decided to take a fresh look at whether the 3rd party component is still necessary. It would be nice to remove the complexity and risk of outside components thruout the application. And, right alignment has been improved in the MaskEdit. But the mask is not what I need. So, I think it's back to the 3rd party component, which displays nicely.

I am curious if the mask that is used on a Field works better. I have some of them set on ClientDataSets used with DBGrids and they look better. But I don't edit there.
0
Patrick
2/29/2012 2:16:10 PM
Reply:

Similar Artilces:

delphi 2010 IDE shows wrong line number in the message window
Hello when I open concrete projects the error insign mark with red incorrect areas of the screen. Also when I compile It error message are shown. but the line number displayed in the message window points to a wrong line in the code window. how do i correct this problem? Regards, Francis > {quote:title=Francisco J Ruiz Nu?ez wrote:}{quote} > Hello > when I open concrete projects the error insign mark with red incorrect areas of the screen. Also when I compile It error message are shown. but the line number displayed in the message window points to a wrong line in the code...

VS ide / delphi ide key map
I'm quit lost in VS ide, F9 run, F8 / F7 Ctrl+Alt+P for tool pallet and the fast find when you type component name F11 to switch to code view / object inspector, the ability to navigate in the object inspector with tab and writing property name. Will someone make a Delphi to VS guide? -- Henning Swiboda wrote: > I'm quit lost in VS ide, F9 run, F8 / F7 > Ctrl+Alt+P for tool pallet and the fast find when you type component > name > F11 to switch to code view / object inspector, the ability to navigate > in the object inspector with tab and writing propert...

Delphi 2006 vs Delphi 2009 IDE stability
Hello, all. I have medium sized project which includes about 20Mb of source code (just size of *.pas files). I use Delphi 2006. There are third party component suites JVCL, DevExpress Bars, Pegasus Imaging. All updates applied. The main problem is IDE stability. About four..five times a day IDE become unstable after intensive usage of code insight functions (most often I press Ctrl+Space key). The best outcome is that I have to save everything and restart the IDE. The worst outcome is when IDE stalls or falls into endless loop of error messages and any unsaved work is lost. OS...

IDE Serial Number does not match Licence Serial Number
I just ordered a boundle key. This is because I have reinstalled all my Delphi versions on a new computer. I installed RAD Studio XE4, RAD Studio XE2 and RAD Studio XE In RAD Studio XE I want to install Intraweb XI. I followed the instructions and first uninstalled Intraweb and then did a install but the install does not not accept the key. The install is called IW11.0.60.exe Please help me. This is very important. /Mikael ...

problem with number/number=number ?
hi i need for below 1/36 = 0,0277777777777778 but result should be 1 3/36 should be 1 35/36 should be 1..... (between 1 and 36)/36 should be 1 36/36  and 37/36 and 45/36 and 71/36 should be 2  (between 72 and 37)/36 should be 2  (between 107 and 73)/36 should be 3  and go on how can i do it ? ThanksMark as me if my question or my answer can be helpful for you :) Hi, I think that (int)(n / 36) + 1 will do the trick  hi it work true without below  result 1 for 1/36 and 4 /36 and 35 /36 .. it is true.. but result 2 for 36/36 . res...

When is a number not a number?
I've got some server script that determines the "SELECTED" entry in a SELECT control. (The code below is a snippet.) If no information is returned then I want the number defaulted a hard-coded value, otherwise, I want number that matches the returned value selected. The defaulted, hard-coded value works but the comparison (i == val) doesn't work if a a value was returned in the information. I've verified that it is indeed a number within the range I want. Why would this comparison fail like this? TIA Alan Rosine <snip> if (docInfo.advPayMonths =...

Maskedit masktype = "number" return a wrong number
I am a little bit confuse about maskedit extender. I have a textbox and masked as number with format "999999.99" when i key in ". 1" (i just type 1 in the most right field, there is "space" between . and 1) it return 0.1, instead 0.01 Is there anyone can explain to me? Where did i worng?  Thanks in advance.     <form id="form1" runat="server">    <div>        <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">&nb...

Comparison between Visual Studio 2008 IDE and Delphi 2010 IDE?
Hi, I wonder which is more programmer friendly. Especially for syntax highlighting and fast code writting, viewing.. Thanks.. Mehmet Fide wrote: > Hi, > > I wonder which is more programmer friendly. Especially for syntax > highlighting and fast code writting, viewing.. > > > Thanks.. See "RAD Studio 2010 vs. Visual Studio 2010" in non-technical group. -- Warm Regards, Lee ...

Delphi IDEs
Is it possible to write applications for Android and touch sensitive screens with Delphi XE4 or later versions of Delphi? Is it possible to write applications for Windows 8 and touch sensitive screens with Delphi XE4 and later versions of Delphi? Pier Pier wrote: > Is it possible to write applications for Android and touch sensitive > screens with Delphi XE4 or later versions of Delphi? iOS support was added in XE4. Android support was added in Delphi XE5. > Is it possible to write applications for Windows 8 and touch sensitive > screens with Delphi XE4 an...

Re: Where is data form wizard in Delphi 2009? [pubic.delphi.ide]
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_21560.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Sample picture showing drag and drop from persistent fields edit window. (Any TField in any TDataset should work, TSomeKindofTable, or TSomeKindofQuery. Warren --JivePart=_21560.zeB8CwDOH5aMJzMl Content-Type: image/jpeg; name="drag_and_drop_from_persistent_fields_editor.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; ...

Is it posible to configure Delphi XE3 IDE to use Delphi 7 compiler/debuger
Hi! Like many other developer out there I have several project which has been developed with older version of Delphi (Delphi 7). Since theese projects rely on some components which are not compatible with newer versions of Delphi (no newer versions available) I'm forced to do any maintnance on theese projects using Delphi 7. Another solution would be to find replacment components which would provide me with same capabilities and work with latest versions of Delphi. But this would probbably require compleete rewritings of my projects (lots and lots of work). So currently I'm using...

Delphi needs this: Designtime 'tasks' panes in MS Visual Web Developer 2008 [picture]
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_8bd4.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" --JivePart=_8bd4.zeB8CwDOH5aMJzMl Content-Type: image/jpeg; name="WeNeedThis.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="WeNeedThis.jpg" iVBORw0KGgoAAAANSUhEUgAAARcAAAEaCAYAAAA7TRMKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAAL1wAAC9cBJXXS8AAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURB VHic...

Delphi 7 IDE
Anyone know where I might go to get some information on a nasty "Debug process already running" message in Delphi 7 IDE? I can't compile any of my D7 projects. I uninstalled and reinstalled D7 but the same message pops up. XE3 is not affected by whatever is happening. All my XE3 programs compile and run fine. Are there any D7 forums left out there? My google search on the problem has yielded nothing useful. On which OS? Delphi 7 works very well under Vista/Seven/Eight if you install it not in C:\Program files (the default) but in a dedicated folder (I use C:\Progs) - d...

what is the best Delphi IDE
Hello, I am making a pool here tell us what is the best Delphi IDE you work with ? isaac sam wrote: > Hello, > I am making a pool here Cool! I'll take care of the drinks. FWIW, reservations made by getting up very early and putting a towel on a deckchair will not be honoured (I'm sure some of our European guests here will recognize the system). -- Rudy Velthuis (TeamB) http://www.teamb.com "What a cruel thing is war: to separate and destroy families and friends, and mar the purest joys and happiness God has granted us in this world; to fil...

Delphi 7 IDE
Sorry, I tried to post this to the IDE group, but got "posting not allowed" error. When starting Delphi 7 (all patches applied), with the load last project option, only the object inspector, object treeview, code window and form show up. The IDE / component bar are not opened. Anyone have this happen before? Is there a fix for it? Nothing found with google or newsgroup search, sorry. Charles Collins wrote: > When starting Delphi 7 (all patches applied), with the load last > project option, only the object inspector, object treeview, code > window and ...

Delphi IDE crashes
Hello, I've got a problem with Delphi 2010. The ide sometimes crashes and crashes and crashes. I've opened a QN but they can't figure it out and redirected us to the http://support.embarcadero.com Page. But we dont have a support agreement with Embarcadero so I ask here. Here is the link to the QN: http://qc.embarcadero.com/wc/qcmain.aspx?d=89563 In short words: The IDE crashes during an oepration like CTRL + Mouseclick at a variable or something like that. If the ide is crashed you can simply open delphi again and again and agian. And it will crashes evertime you use CTRL + mouseclick. But sometime ago the function will work properly again. The IDE also crashes if I use CTRL + D, CTRL + Shift + F, and so on. It dont crashing at every action but it crashes for about 10 to 30 times a day. Reinstall didnt help anything. With Best Regards Uwe Graßhoff Uwe Graßhoff wrote: > I've got a problem with Delphi 2010. The ide sometimes crashes and > crashes and crashes. Do you have any thirparty IDE experts installed? If yes then unistall those to see does it make difference. ain > {quote:title=Ain Valtin wrote:}{quote} > Uwe Graßhoff wrote: > > > I've got a problem with Delphi 2010. The ide sometimes crashes and > > crashes and crashes. > > Do you have any thirparty IDE experts installed? If yes then unistall > those to see does it make difference. > >...

Delphi IDE version
We have a help, about form with various info. I already have the Application version on here. I would like to incluude the Delphi IDE version here also XE2 is our latest version. Rather than hard coding in the code, is there a runtme option that returns the Delphi IDE version that app was created with? "Larry Wall" wrote in message news:626381@forums.embarcadero.com... > We have a help, about form with various info. > I already have the Application version on here. > I would like to incluude the Delphi IDE version here also XE2 is our > latest version. > Rat...

How is made the Delphi IDE ?
Hello Some years ago it was clear (for me) that Delphi was written in...Delphi + VCL. Is it always true ? Are there some informations about it ? I curious about editor because it is quite clean and efficient, and is 'customised' with some third party software like CnPack, do they have acces to sources or new functions are done via a plug in ? Am 26.07.2013 10:11, schrieb phil prost: > Hello > Some years ago it was clear (for me) that Delphi was written in...Delphi + VCL. Is it always true ? Are there some informations about it ? > I curious about editor because it is q...

Delphi 2006
Hello all, I'm using BDS 2006 Pro, Win XP Pro SP2. I'm having a problem in Delphi 2006 (Win32). A couple of months ago, Delphi hung and I killed the process. Since then, when I open a project, the Object Inspector and Tool palette do not show unless I select them from the View menu. I have to do this every time I open Delphi. Will repairing the installation fix this problem? If I repair the installation, will I have to reinstall all of my third party components? Thanks, David My IDE was defaulting to Debug Layout instead of Default Layout. I knew I had seen...

Unable to start Delphi IDE
Hi all, All of a sudden I'm no longer to start Delphi 2010 if have started it once before Upon starting the second time (after closing the first time) I get this error Cannot create file "C:\Users\[USERNAME]\AppData\Local\Temp\EditorLineEnds.ttr". The process cannot access the file because it is being used by another process. The file is definitely not being used by another process. At this point only restarting Windows allows re-starting Delphi 2010. Any idea what may be causing this? Thanks in advance, Gerrit Beuze ModelMaker Tools > > maybe this ...

Turbo Delphi IDE bug ?
in Delphi 7 will be notified if source modified from outside delphi IDE or by another user but in Turbo Dephi not happen. Is Turbo Delphi bug ? sorry my english bad Imam Chalimi Malang, Indonesia ...

IDE crash with Delphi 2009
Hi, I recently bought Delphi 2009 and tried upgrading a rather big project. However, the IDE completely disappears every time I try to compile. After a few hours of debugging I found the offensive code and noticed there is already a QC for it: http://qc.codegear.com/wc/qcmain.aspx?d=66966 However, such a huge bug has not made it into SP1. This is really a show stopper for me, as I can't compile my program; finding all the instances of my code that crash the compiler would take me a really long time which I do not want to invest, as I hope this bug will eventually get fixed. ...

How to use MaskEdit for phone number?
Is there a way to manipulate the MaskEdit AJAX for phone number in the following formating? (123) 456-7890 If so, will someone show me how this is done? Many thanks!  Set the Mask Property to the following: Mask="(999) 999-9999"Please remember to mark this post as an [Answer] if you found it helpful. Thanks so much! That works perfect....

Delphi IDE on Android tablet
Delphi IDE on Android tablet http://www.citeworld.com/development/21406/wine-android-sorry-youre-going-have-wait Delphi <-> Wine <-> x86-Android tablet Wouldn't that a good business case? Another prerequisite would be a slim Delphi IDE. > {quote:title=Ralf Stocker wrote:}{quote} > Delphi IDE on Android tablet > > > http://www.citeworld.com/development/21406/wine-android-sorry-youre-going-have-wait > > > Delphi <-> Wine <-> x86-Android tablet > Do you mean for running the Delphi IDE or for producing Androi...

Web resources about - MaskEdit for Numbers - embarcadero.delphi.ide

New Technology Kit
Official NTK Project for xHarbour webpage

Resources last updated: 3/25/2016 7:19:29 AM