简体   繁体   中英

sudden change in string value during a browse value change

During a Value-Change inside a browse, my string value suddenly changes, specifically the string(9) will change to string(0).

sample:

in my combo-box, i used a list-item-pair with following code:

cb-name:LIST-ITEM-PAIRS = ?.
cb-name:DELIMITER = '?'.
FOR EACH employee WHERE employee.date-resigned = ? NO-LOCK BY employee.employee-no.
    cb-name:ADD-LAST(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + ".",employee.employee-no).
END.
cb-name:SCREEN-VALUE = cb-name:ENTRY(1).

in the value-changed of browse:

ASSIGN cb-name:SCREEN-VALUE = 
STRING(TRIM(STRING(employee.employee-no, '99999999') + " - " + employee.last-name + ", " + employee.first-name + " " + SUBSTRING(employee.middle-name,1,1)) + "." , 
       STRING(employee.employee-no, '99999999')).

if the employee no has a string value of 9, progress will change it to 0.. producing an error message that has an invalid value..

ex: from 819001 /*correct*/ to 810001 /*incorrect*/

if there is no string(9), it will display like:818002

if i message the STRING(employee.employee-no, '99999999')), it will display the correct string value

Version doesn't matter in this case, apparently. I just simulated it in 10.2B08 using a temp-table with the named tables. The problem is when you're assigning the screen-value to the combo you're trying to convert the whole string (employee-no + names + separators) into format 99999999. Since your combo is list-item-pairs ('Whatever I want it to display','the real value', 'and so on display' , 'and so forth value') your solution is to assign the screen value just to the real value, disregard the label. In other words, as simple as changing your value-changed code to

ASSIGN cb-name:SCREEN-VALUE = STRING(employee.employee-no, '99999999') .

It worked for me. Let me know if you are still having trouble with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM