Hi,
I'm new to Lansa. Can someone help on how to format a string to have leading zeros.
e.g.
34 = 000034
434 = 000434
Thanks
Chandima
Adding leading Zeros to a number
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Adding leading Zeros to a number
Hi Chandima
Here's a simple webpage with a number entry field.
The number is converted to a string and then right adjusted to a specific length. Zero is then used as the pad character to replace any spaces.
Regards
Here's a simple webpage with a number entry field.
The number is converted to a string and then right adjusted to a specific length. Zero is then used as the pad character to replace any spaces.
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB) Height(616) Width(888)
Define_Com Class(#xDemoNumber.Visual) Name(#Number) DisplayPosition(1) Left(24) Parent(#COM_OWNER) TabPosition(1) Top(16) Height(25)
Define_Com Class(#PRIM_LABL) Name(#FormattedNumber) Caption('Formatted Number') DisplayPosition(2) Ellipses(Word) Height(25) Left(336) Parent(#COM_OWNER) TabPosition(2) TabStop(False) Top(14) VerticalAlignment(Center) Width(233)
Evtroutine Handling(#Number.Changed)
#FormattedNumber := #Number.AsString.RightAdjust( 6 "0" )
Endroutine
End_Com