KickStarter15 Posted December 18, 2018 Share Posted December 18, 2018 Hi Experts, Good day! I have this small issue on how to add leading zeros to the result given by "$Sum = Number(GUICtrlRead($Input1) - 111)". I have my $Input1 = 117, now when using number() it will result to "6" instead of "006". It's just to compute 117 - 111 which should have the result of "006". Is this possible or is there any way to have that kind of result? Thanks, Experts! KS15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Subz Posted December 18, 2018 Share Posted December 18, 2018 MsgBox(4096, "", StringFormat("%03i", 6)) Link to comment Share on other sites More sharing options...
Malkey Posted December 18, 2018 Share Posted December 18, 2018 The StringRight() function can be used. And here is another StringFormat() example. MsgBox(0, "Leading zeros", StringRight("000" & (117 - 111), 3)) ; Returns 006 (3 characters from the right) ; Or MsgBox(4096, "Leading zeros", StringFormat("4 characters with leading zeros %04i\n3 characters with leading zeros %03i\n2 characters with leading zeros %02i", 8, 117 - 111, 5)) #cs ; Returns :- 4 characters with leading zeros 0008 3 characters with leading zeros 006 2 characters with leading zeros 05 #CE Link to comment Share on other sites More sharing options...
KickStarter15 Posted December 20, 2018 Author Share Posted December 20, 2018 Thanks, Experts. Both are working. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now