怎么用代码控制在TEXT1中只能输入数字,谢谢!

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii > 57 Or KeyAscii < 48 Then KeyAscii = 0
    End Sub
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii <> 8 Then
        If (KeyAscii >= 48 And KeyAscii <= 58) Or KeyAscii = 46 Then
        Else
            KeyAscii = 0
        End If
    End If
    End Sub8是退格键,46是小数点
      

  3.   

    好像可以用 IsNum 函数判断
    最简单的是用VB的MaskEdit控件。