Highlighted
Outstanding Contributor.
Outstanding Contributor.
1153 views

Spaces in a filed text

Jump to solution

I'm having a problem in text fields that come from the MySql database.
I'm using the following statement:
EXEC SQL SELECT bdname INTO wrk-name FROM Costumer (the wrk-name is the PIC X (50).
Then I'm using:
set txtName:: Text to wrk-name
What happens is that the campio txtNAME is completely filled (50 characters) not allowing write nothing but nullifying the blank spaces.

How can I resolve the issue?

(Visual Cobol 2.2 with WPF)

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Spaces in a filed text

Jump to solution

If you are trying to suppress trailing spaces in a text field you could set it using the TrimEnd method like:

set txtName::Text to wrk-name::TrimEnd

TrimEnd is actually a method on the string class but it can be used on pic x items as well as they are treated as strings behind the scenes.

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Spaces in a filed text

Jump to solution

If you are trying to suppress trailing spaces in a text field you could set it using the TrimEnd method like:

set txtName::Text to wrk-name::TrimEnd

TrimEnd is actually a method on the string class but it can be used on pic x items as well as they are treated as strings behind the scenes.

View solution in original post

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Spaces in a filed text

Jump to solution

Thanks for your flash response. It´s working.

I should like to put two little questions:

-Is there any way to create numeric only fields?

-Is there any way to create an input field for dates where the user only put the month and year and assume the system "/".

In NetExpress created the field with 99/99/9999 Pic. Is there anything like that?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Spaces in a filed text

Jump to solution

What you are looking for is a MaskedTextbox control. There is not one provided in the default WPF control collection but there is one available in the  Extended WPF Toolkit which can be downloaded here:

The NuGet package manager does not currently work with Visual COBOL but you can download the toolkit binaries and then add the controls to your Toolbox following the instructions here

This will allow you to create entry fields that support the insertion of literal characters as well as allowing only specific characters to be entered.

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.