August 3, 2009 at 10:49
filed under Dynamics AX
Tagged Data Types, Dynamics AX, String
Sometimes, you’ll want to add leading zeros, but other times, you’ll have to remove leading zeros from a string.
Here the code that does just that:
The above example will work for any alphanumeric string.
When you’re sure you’re dealing with numeric strings, you can use this example:
You should build in a check because the str2int() function doesn’t throw an error when the input isn’t numeric.
An example I found online also removes leading zeros from a string, but it fails if the first character after the zeros isn’t numeric:
Conclusion:
The first example works best, but you should still be careful when converting the resulting string to other types, as you could get unexpected results.
no comments
RSS / trackback