Convert 4 digit number to 5 digit number beginning with 0?

Trying to figure out an expression to convert numbers that are 4 digits to 5 digits beginning with 0.

Such as 1605 to 01605

While at the same time leaving 5 digit numbers alone such as 16058 as 16058

Not certain how to go about using the len or if I even need to gather the length of the number.

for i in 0{1000…9999} {10000…99999}
???

Just wanting to:

take the value from a numeric text field box
add a 0 to the beginning of the number if 4 digits in length to make it 5
then have it available to be bound to another numeric text field box

Any thoughts of how this could be accomplished?

Set the Decimal Format Property of the Numeric Text Box to “00000”. That will force the digit. a “#” eliminates leading or trailing zeroes. No expression or script required. :wink:

Jordan,

Thanks much closer. I can see the number formatted correctly, but how can I get the number bound to another component with that formatting?

When I bond it to another it is formatted without the leading 0.

I tried on the component expression:

numberFormat({Root Container.Dropdown.selectedValue}, “00000”)

Ultimately I would like to be able to bond the value with the leading 0 to a custom property for a report.

Thanks
Casey

I have the value writting to a int4 memory tag with that number formatting and the value shows correctly.

When I bond that memory tag to the custom int property of the report, the formatting appears to be dropped.

Data types. Although the value is numeric, for processing purposes you are treating it like a string. I am not sure why you are doing this, but if it is required you will need to convert to string and then bind on the converted tag.

[quote="cswett"]I have the value writting to a int4 memory tag with that number formatting and the value shows correctly.

When I bond that memory tag to the custom int property of the report, the formatting appears to be dropped.[/quote]

Just so I'm on the same page, you mean the reporting module, right?

That'd be a final workaround, but it should be possible to do with the format string in the report. Also, if there's any math that would have to be done to it within the report, then a string won't cut it.

Since you mentioned a custom property for the report, I’m assuming the Reporting Module.

After adding a custom integer property to the report viewer: