activex文本框控件_一个将输入限制为数字的文本框ActiveX控件

activex文本框控件

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone to do so.

您是否曾经想过将用户在文本框中输入的内容限制为数字,并同时确保通过粘贴非数字文本不能“欺骗”用户? 当然,您可以使用自己编写的代码来做到这一点,但是这样做既乏味又容易出错。

The attached control is a modified TextBox does all that for you and it also has these additional properties:

附带的控件是经过修改的TextBox,可以为您完成所有操作,并且还具有以下其他属性:

CanHaveDecimals - This is a Boolean property that determines if the number can have decimals or not

CanHaveDecimals-这是一个布尔型属性,确定数字是否可以有小数

CanBeNegative - This is a Boolean property that determines if the number can be negative or not

CanBeNegative-这是一个布尔型属性,确定数字是否可以为负数

MaxDecimals - This property allows the user to set the maximum allowable number of decimals

MaxDecimals-此属性允许用户设置最大允许的小数位数

MinValue - This property allows the user to set the minimum acceptable value

MinValue-此属性允许用户设置最小可接受值

MaxValue - This property allows the user to set the maximum acceptable value

MaxValue-此属性允许用户设置最大可接受值

DecimalSeparator - This property determines which character ("." or ",") is used as the decimal separator

DecimalSeparator-此属性确定哪个字符(“。”或“,”)用作小数点分隔符

RequireLeadingDigit - This is a Boolean property that determines if at least one digit must preceed the decimal separator

RequireLeadingDigit-这是一个布尔属性,确定是否必须在小数点分隔符之前至少包含一位数字

Here is a link to the code which once compiled will add the NumberBox to the list of available project Components. You can add the control to a project by going to Project|Components and checking NumberBox. I would have liked to be able to attach the code here in a zip file, but the zip contains file types that Experts Excgange won't allow to be uploaded even though they are all perfectly valid VB file types. 是代码的链接,一旦编译,该代码会将NumberBox添加到可用项目组件的列表中。 您可以通过转到Project | Components并选中NumberBox将控件添加到项目中。 我希望能够在zip文件中附加代码,但是zip包含Expert Excgange不允许上传的文件类型,即使它们都是完全有效的VB文件类型。

Note that this control is fairly widely used (for a 3rd-party OCX) on another site and has gone through 16 versions with associated version testing so it is thoroughly tested. Having said that if you do find a problem please let me know the details and I'll attempt to correct it.

请注意,此控件在另一个站点上已广泛使用(对于第三方OCX),并且已通过16个版本并进行了相关版本测试,因此已对其进行了全面测试。 话虽如此,如果您确实发现了问题,请让我知道详细信息,我将尝试纠正它。

If you find that this article has been helpful, please click the “thumb’s up” button below. Doing so lets me know what is valuable for EE members and provides direction for future articles. It also provides me with positive feedback in the form of a few points. Thanks!

如果您发现本文对您有所帮助,请单击下面的“竖起大拇指”按钮。 这样做可以让我知道对EE成员有价值的内容,并为以后的文章提供指导。 它还以几点的形式为我提供了积极的反馈。 谢谢!

翻译自: https://www.experts-exchange.com/articles/8635/A-Textbox-ActiveX-Control-That-Limits-Input-to-Numbers.html

activex文本框控件

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值