简体   繁体   English

文本框应仅允许整数。 在vb.net中不是十进制

[英]Textbox should allow only Integer. not decimal in vb.net

I want to allow only whole values and not decimal to the textbox in vb.net. 我想在vb.net的文本框中只允许使用整个值,而不能使用十进制。 Can anyone help me how to check validation on that. 谁能帮助我如何检查这一点。

Only allow numeric input: 只允许数字输入:

    Private Sub TextBoxKeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress
            e.Handled = True
            If IsNumeric(e.KeyChar) Then e.Handled = False
        End Sub

For a more elaborate example : http://msdn.microsoft.com/en-us/library/ms229644(v=vs.80).aspx 有关更详细的示例: http : //msdn.microsoft.com/zh-cn/library/ms229644(v=vs.80).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 VB.NET 中,如何让文本框只允许一个小数点,&lt; 3NUMBERS 之前,只有 1NUMBER 之后? - In VB.NET how do I get a textbox to only allow one decimal point, < 3NUMBERS before it, and only 1NUMBER after it? 在ASP.NET文本框中仅允许数字或十进制数据 - Allow only numeric or decimal data in asp.net textbox vb.net中的文本框光标 - Textbox cursor in vb.net 如何验证ASP.Net TextBox应该允许带三个小数位的负或正十进制值? - How to validate a ASP.Net TextBox which should allow negative or positive decimal value with three decimal places? 在插入数据库ASP.NET VB.NET之前将文本框字符串转换为Integer - Converting textbox string to Integer prior to inserting into database ASP.NET VB.NET 如果没有从下拉列表中选择任何值,则允许文本框添加到数据库VB.net - If no value selected from dropdown, allow textbox to add to database VB.net Vb.net简单文本框转换为整数给出错误的输入字符串格式不正确 - Vb.net Simple TextBox conversion to integer gives error input string was not in a correct format 使用vb.net Web格式验证文本框 - Validate textbox with vb.net web forma 如何在vb.net中生成动态文本框 - How to generate dynamic textbox in vb.net 使用MySql在vb.net中自动完成文本框 - Autocomplete Textbox in vb.net using MySql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM