如何保留数字中可能的前导零? [英] How to preserve possible leading zeros in a number?

查看:110
本文介绍了如何保留数字中可能的前导零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以保留数字中可能的前导零,即使它作为文本传递?

我在表单上有这个代码,该表单运行一个命令按钮,从用户输入获取两个值,将它们传递给函数并将返回的值作为字符串放回到thrid文本框中(''regNo'')。

函数''generatecode''正确返回一串数字它可能在6到11位数之间,可能包含0到3个前导零。当我尝试将此字符串放在文本框中时,问题出现在第8行。

Is there a way to preserve possible leading zeros in a number even when it is passed as text?
I have this code on a form which runs off a command button taking two values from user input, passing them to a function and is placing the returned value as a string back in a thrid textbox (''regNo'').
The function ''generatecode'' is correctly returning a string of digits which may be between 6 to 11 digits long and might contain between 0 and 3 leading zeros. The problem occurs at line 8 when I try to place this string in the text box.

展开 | 选择 | Wrap | 行号

推荐答案

什么是regNo?您说它是表单上的文本框,但它绑定的字段类型,文本字段或数字字段。如果是文本字段,它应该可以正常工作。


如果regNo未绑定,请尝试使用


Me.reNo =将其强制为字符串chr(34)&传递与传播chr(34)


并查看是否有效。
What is regNo? You say it is a textbox on the form but what type of field is it bound to, a text field or a numeric field. If a text field, it should work fine.

If regNo is unbound, try forcing it to a string using

Me.reNo=chr(34) & pass & chr(34)

and see if that works.


Hello Lysander

很好的尝试,但这是产生一个错误 - 是的,文本框未绑定。这是为了生成一个代码,用于作为电子邮件的一部分发送。

Deekay
Hello Lysander
Good try but this is generating an error - and yes the textbox is unbound. It''s meant to generate a code for sending as part of an e-mail.
Deekay


是generatecode()函数的返回值字符串,明确说明,如:
Is the Return Value of the generatecode() Function a String, explicitly stated, as in:
展开 | 选择 | Wrap | 行号


这篇关于如何保留数字中可能的前导零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆