Highlighted
Alex_Castro Respected Contributor.
Respected Contributor.
59 views

Suppression of Leading Zeroes in Numeric Mask Text Box Control

Jump to solution

I have a masked text box control on my windows form which I want to use in order to display a SSN to the user. I chose a predefined mask description in the properties windows and it looks as follows: 000-00-0000.

When I move a value that has leading zeroes to my mask text box, however, it drops the leading zeroes. For example, if I move a value of '000001234' to the mask text box, it displays it as follows:  123-4_-____. 

I works well if there are no leading zeroes. If I move the value '123456789'  to the mask text box for example, it displays it correctly as follows: '123-45-6789'. 

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: Suppression of Leading Zeroes in Numeric Mask Text Box Control

Jump to solution

This is expected behavior if you are moving an actual numeric field or value to the Text property but it should work correctly if this is converted to a string first.

set MaskedTextBox1::Text to "000123456"    *> this will work
set MaskedTextBox1::Text to 000123456       *> this will have the zeroes stripped as it is an integer

Does this work for you?

If you are using a numeric field like pic 9(9) you could move it to a pic x(9) field and then use this as your sending field.

View solution in original post

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

Re: Suppression of Leading Zeroes in Numeric Mask Text Box Control

Jump to solution

This is expected behavior if you are moving an actual numeric field or value to the Text property but it should work correctly if this is converted to a string first.

set MaskedTextBox1::Text to "000123456"    *> this will work
set MaskedTextBox1::Text to 000123456       *> this will have the zeroes stripped as it is an integer

Does this work for you?

If you are using a numeric field like pic 9(9) you could move it to a pic x(9) field and then use this as your sending field.

View solution in original post

0 Likes
Alex_Castro Respected Contributor.
Respected Contributor.

Re: Suppression of Leading Zeroes in Numeric Mask Text Box Control

Jump to solution

Your suggestion worked! I created a temporary field and declared it as follows:

01 TMP-SSN PIC X(09)

I then moved my numeric field into the the temporary field and sent the temporary field to the text box as follows:

MOVE EMPL-SSN TO TMP-SSN

MOVE TMP-SSN TO msk-EMP-SSN::Text

 

Thanks for your help!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.