TGH Posted September 16, 2008 Report Share Posted September 16, 2008 Hi, I'm trying to Pad an number with leading zeros. For example 1 would be 00001 or 2 would become 00002 etc. I see from the manual I can pad with leading blanks, but that doesn't help me. Any ideas on how to solve my problem? Thanks for any help. Quote Link to comment Share on other sites More sharing options...
stan Posted September 16, 2008 Report Share Posted September 16, 2008 Hi, Here is a sample of how I would approach this. <TVAR2:01:02:FFFCenter:Center><TMVAR2:14:01:00:005:000:><TMVAR2:21:01:01:000:000: 0> You first need to save the number to a text string variable. This example just uses the Variable Set String - Prompt for Value command. The next step uses the Variable Modify String command to pad the string. The last step also modifies the string, Replace Substring. In the Text to Replace field press the Space Bar once. In the Replace With Field enter zero (0). Check the Replace all Instances box and save. So if you set the pad string option to 5, the macro will insert 4 zeroes if the original number is only one digit. If two digits, then 3 zeroes are added, etc. Quote Link to comment Share on other sites More sharing options...
TGH Posted September 17, 2008 Author Report Share Posted September 17, 2008 Hi, Here is a sample of how I would approach this. <TVAR2:01:02:FFFCenter:Center><TMVAR2:14:01:00:005:000:><TMVAR2:21:01:01:000:000: 0> You first need to save the number to a text string variable. This example just uses the Variable Set String - Prompt for Value command. The next step uses the Variable Modify String command to pad the string. The last step also modifies the string, Replace Substring. In the Text to Replace field press the Space Bar once. In the Replace With Field enter zero (0). Check the Replace all Instances box and save. So if you set the pad string option to 5, the macro will insert 4 zeroes if the original number is only one digit. If two digits, then 3 zeroes are added, etc. Thanks very much that worked for me. I appreciate the help. Quote Link to comment Share on other sites More sharing options...
blopib Posted September 26, 2008 Report Share Posted September 26, 2008 Thanks very much that worked for me. I appreciate the help. I often do this in excel, if 1 is in the cell A1, you can use =TEXT(A1;"00000") in eg. the cell A2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.