Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-08

Percentage and Currency in MaskEdit

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart
to ik

For example set EditMask to #9999.99;_;1
This will accept numbers with a (optional) preceeding plus or minus symbol, followed by 4 (optional) digits, a decimal point, followed by 2 (optional) digits.
You might consider replacin the hard coded decimal point with the value of DecimalSeparator.

The Text property may contain spaces when you read it, which you will have to filter out before processing.

Another (probably easier) option would be to use a TFloatSpinEdit as input, and specify Min and Max values and the number of decimals.

Bart

ik wrote 12 lines
Hello List, I'm trying to build a small app that should accept percentages of a price and also the price itself (regardless of the percentages. I'm using TCurrency to save both, however how can I (if it possible) to use a Mask for such types of input ? Thanks, Ido http://ik.homelinux.org/
Dimitri Smits
----- "Bart" wrote 7 lines
For example set EditMask to #9999.99;_;1 This will accept numbers with a (optional) preceeding plus or minus symbol, followed by 4 (optional) digits, a decimal point, followed by 2 (optional) digits. You might consider replacin the hard coded decimal point with the value of DecimalSeparator.

I'm thinking that the OP meant "display a currency symbol as well". Either way, a mask of '#999,990.00;_;1' is maybe cleaner. as for the '.' and ',', they are placeholders for the decimalseparator and thousandseparator and are replaced by the correct ones. At least, that was the case in Delphi if I remember correctly. (been a long time since I made anything international :-))

Show quoted text 23 lines
The Text property may contain spaces when you read it, which you will have to filter out before processing. Another (probably easier) option would be to use a TFloatSpinEdit as input, and specify Min and Max values and the number of decimals. Bart On 8/26/10, ik wrote: > Hello List, > > I'm trying to build a small app that should accept percentages of a price > and also the price itself (regardless of the percentages. > I'm using TCurrency to save both, however how can I (if it possible) to use > a Mask for such types of input ? > > Thanks, > > Ido > http://ik.homelinux.org/ >
ik
to Dimitri Smits

Thanks for the ideas.

I might even work tomarrow on making TDBXXSpinEdit for working databases as Bart suggested.

Ido

http://ik.homelinux.org/

Dimitri Smits wrote 48 lines
----- "Bart" schreef: > For example set EditMask to #9999.99;_;1 > This will accept numbers with a (optional) preceeding plus or minus > symbol, followed by 4 (optional) digits, a decimal point, followed by > 2 (optional) digits. > You might consider replacin the hard coded decimal point with the > value of DecimalSeparator. > I'm thinking that the OP meant "display a currency symbol as well". Either way, a mask of '#999,990.00;_;1' is maybe cleaner. as for the '.' and ',', they are placeholders for the decimalseparator and thousandseparator and are replaced by the correct ones. At least, that was the case in Delphi if I remember correctly. (been a long time since I made anything international :-)) > The Text property may contain spaces when you read it, which you will > have to filter out before processing. > > Another (probably easier) option would be to use a TFloatSpinEdit as > input, and specify Min and Max values and the number of decimals. > > Bart > > On 8/26/10, ik wrote: > > Hello List, > > > > I'm trying to build a small app that should accept percentages of a > price > > and also the price itself (regardless of the percentages. > > I'm using TCurrency to save both, however how can I (if it possible) > to use > > a Mask for such types of input ? > > > > Thanks, > > > > Ido > > http://ik.homelinux.org/ > > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100827/bcd5b206/attachment.html>