用前导零填充固定数字,直到固定长度 [英] Padding a fixed number with leading zeros up to a fixed length
本文介绍了用前导零填充固定数字,直到固定长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用 Visual Studio 2010 的 Crystal Report 中,我正在尝试为以下场景创建一个公式:
In Crystal Report using Visual Studio 2010, I am trying a to create a formula for the following scenario:
x = 任意数(固定为 8 位,不能小于或大于)
x = any number (Fixed number of 8 digits, cant be less or greater)
如果 X 的长度小于 8,则在前面填充所需数量的 0,使其长度为 8.
If Length of X is less than 8, pad the required amount of 0's in the front to make its length 8.
例如:
X = 123
Result of Formula should be 00000123
X = 9
Result of Formula should be 00000009
任何帮助将不胜感激.提前致谢.
Any help will be appreciated. Thanks in advance.
推荐答案
我明白了
Right("0000"&{MyFieldToPad},8)
按照我的意愿完美运行.
Works perfectly as I want it to.
这篇关于用前导零填充固定数字,直到固定长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文