现在的位置: 首页 > 综合 > 正文

让textbox控件中只能输入数字的代码

2013年12月06日 ⁄ 综合 ⁄ 共 262字 ⁄ 字号 评论关闭

在控件的keyPress事件中,添加如下代码:

   Private Sub t2008a_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles t2008a.KeyPress、

        If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
            e.Handled = True
        End If

    End Sub

抱歉!评论已关闭.