papsphilip Posted September 26 Share Posted September 26 trying to use a variable for sprintf instead of hardcoding the number of leading zeros. is that possible? string pad = '%0' + var + 'd'; string padnum = sprintf(pad, numbertopad); Quote Link to comment Share on other sites More sharing options...
DLCool Posted September 27 Share Posted September 27 Hi, there. Try something like this: int padding = 5; int number = 44; string attr = sprintf("%*0d", padding, number); 1 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.
Note: Your post will require moderator approval before it will be visible.