小弟有一个问题啊!
就是在文本框中只能输入0-9这10个数字字符,不能输入其他的文本字符: 
我用的是下面的代码,但是无效
Private Sub Text1_Change()
    If KeyAscii < 48 Or KeyAscii > 57 Then
        KeyAscii = 0
    End If
End Sub 
请教各位大侠,这是怎么回事啊!小弟在此不胜感激啊!

解决方案 »

  1.   

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)End Sub
    用介个事件
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)    Select Case KeyAscii
            Case 48 To 57
            Case 46
            Case 8
            Case Else
                KeyAscii = 0
        End Select
    End Sub
      

  3.   

    to General521: 你也太粗心了,后面的几位大哥也看清楚
    Private Sub Text1_Change()
        If KeyAscii < 48 Or KeyAscii > 57 Then
            KeyAscii = 0
        End If
    End Sub 
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii < 48 Or KeyAscii > 57 Then
            KeyAscii = 0
        End If
    End Sub 
    好好的看看书.用第二个
    你在试一下
      

  4.   

    楼主不好意思小弟多写了2个符号Private Sub Text1_KeyPress(KeyAscii As Integer)    Select Case KeyAscii
            Case 48 To 57
                    Case Else
                KeyAscii = 0
        End Select
    End Sub