11
Advanced EZGUI / Re: Number Component
« Last post by Chris Boss on July 17, 2024, 02:33:22 pm »Just for your info, EZGUI has a masked edit control which can do this.
From the Help file under the EZ_Text command:
Masked Edit Features
EZGUI converts the standard Text (Edit) control to a Masked Edit control if you define a Mask in the CProp$ parameter (after the properties). The Mask is a set of characters between { } characters (curly brackets). For example, a Mask for a telephone number would be:
"{(999)999-9999}"
The Mask must be added to the CProp$ (properties) parameter after the standard properties are listed ( ie. "ESTG({999)-999-9999}" )
The Text field will also be set to a maximum length based on the length of the Mask. The Mask characters are defined below.
Standard Mask Characters:
X - Any Character
A - Alpha Character only and Space
U - Alpha Character only and Space. Converted to Upper case !
9 - Digits only (0 to 9)
# - Digits (0 to 9) and space, +, - and period
N - AlphaNumeric and Space
L - Logical (Y/N or T/F)
Y - Logical (Y/N)
T - Logocal (T/F)
P - PlaceHolder when not using E property (means Read Only)
Examples of Standard Masks:
(999)999-9999 - Telephone number
XXXXXXXXXX - Any text
AAAAAAAAAA - Alpha only
UUUUUUUUU - Uppercase only
UUU-9999999 - Part number
99/99/9999 - Date
All other non-mask characters will be used "as is". They are frozen and can't be edited. If the Text Control is multiline, the Mask property is ignored. If the Text Control is readonly (does not have E (edit) property), then all mask characters are converted to P (Placeholder) mask character.
Calculator Mode Mask Characters:
+ - This mask allows a Space (for Plus) or a minus sign ( - )
and is used only in the first character position of a
calculator mode mask.
# - Floating Point Mask
(you can use a fixed decimal with this mask)
% - Whole Number Mask
$_ - When a Dollar sign and a space are put to the
left of a Calculator mode mask, then a $ and
space will appear to the left in the textbox.
ie. "$ ###.##"
_% - When a space and % character are put at the
end of a Calculator mode mask, then a space
and % character will appear in the textbox at
the far right.
ie. "{##.## %}"
Examples of Calculator mode masks:
%%%%%% - Whole number (positive only)
+%%%%% - Whole number (positive or negative)
######## - Floating Point number (positive only)
+####### - Floating Point number (positive or negative)
#####.## - Floating Point number
(positive and fixed decimal)
+####.## - Floating Point
(positive or negative and fixed decimal)
$ ###.## - Floating Point with $ (and space) to left
###.## % - Floating Point with (space and ) % to right
When using a Calculator Mode Mask the Text control will allow entry of a real number and the characters will display Right to Left, like a calculator does. You can also add a + sign as the first character to allow plus or minus values ( ie. {+####} ). Also you can add just one decimal point ( ie. {+###.###} ). Using this format, you can mask Integers and real Numbers (with decimal).
Caret Position !
By default the Mask Edit control will set the caret position at the first character when the control gets the Focus. If you want the control to remember the previous position of the caret (character position cursor) then put a ? character in front of the mask (ie. {?XXXX} ). Masks that define a Calculator mode mask, always set the caret at the end of the text field, so the ? mask character has no effect.
You can now use the Backspace key in most masks ! The control will determine the proper character to replace text with. For example, if the mask character is X, A, U or N it will use a space. If the mask character is a 9 (digits only) it will use a 0 (zero) when back spacing.
From the Help file under the EZ_Text command:
Masked Edit Features
EZGUI converts the standard Text (Edit) control to a Masked Edit control if you define a Mask in the CProp$ parameter (after the properties). The Mask is a set of characters between { } characters (curly brackets). For example, a Mask for a telephone number would be:
"{(999)999-9999}"
The Mask must be added to the CProp$ (properties) parameter after the standard properties are listed ( ie. "ESTG({999)-999-9999}" )
The Text field will also be set to a maximum length based on the length of the Mask. The Mask characters are defined below.
Standard Mask Characters:
X - Any Character
A - Alpha Character only and Space
U - Alpha Character only and Space. Converted to Upper case !
9 - Digits only (0 to 9)
# - Digits (0 to 9) and space, +, - and period
N - AlphaNumeric and Space
L - Logical (Y/N or T/F)
Y - Logical (Y/N)
T - Logocal (T/F)
P - PlaceHolder when not using E property (means Read Only)
Examples of Standard Masks:
(999)999-9999 - Telephone number
XXXXXXXXXX - Any text
AAAAAAAAAA - Alpha only
UUUUUUUUU - Uppercase only
UUU-9999999 - Part number
99/99/9999 - Date
All other non-mask characters will be used "as is". They are frozen and can't be edited. If the Text Control is multiline, the Mask property is ignored. If the Text Control is readonly (does not have E (edit) property), then all mask characters are converted to P (Placeholder) mask character.
Calculator Mode Mask Characters:
+ - This mask allows a Space (for Plus) or a minus sign ( - )
and is used only in the first character position of a
calculator mode mask.
# - Floating Point Mask
(you can use a fixed decimal with this mask)
% - Whole Number Mask
$_ - When a Dollar sign and a space are put to the
left of a Calculator mode mask, then a $ and
space will appear to the left in the textbox.
ie. "$ ###.##"
_% - When a space and % character are put at the
end of a Calculator mode mask, then a space
and % character will appear in the textbox at
the far right.
ie. "{##.## %}"
Examples of Calculator mode masks:
%%%%%% - Whole number (positive only)
+%%%%% - Whole number (positive or negative)
######## - Floating Point number (positive only)
+####### - Floating Point number (positive or negative)
#####.## - Floating Point number
(positive and fixed decimal)
+####.## - Floating Point
(positive or negative and fixed decimal)
$ ###.## - Floating Point with $ (and space) to left
###.## % - Floating Point with (space and ) % to right
When using a Calculator Mode Mask the Text control will allow entry of a real number and the characters will display Right to Left, like a calculator does. You can also add a + sign as the first character to allow plus or minus values ( ie. {+####} ). Also you can add just one decimal point ( ie. {+###.###} ). Using this format, you can mask Integers and real Numbers (with decimal).
Caret Position !
By default the Mask Edit control will set the caret position at the first character when the control gets the Focus. If you want the control to remember the previous position of the caret (character position cursor) then put a ? character in front of the mask (ie. {?XXXX} ). Masks that define a Calculator mode mask, always set the caret at the end of the text field, so the ? mask character has no effect.
You can now use the Backspace key in most masks ! The control will determine the proper character to replace text with. For example, if the mask character is X, A, U or N it will use a space. If the mask character is a 9 (digits only) it will use a 0 (zero) when back spacing.