text_chang()中屏蔽掉其他键

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyTab Then Exit Sub
        If KeyAscii = vbKeyBack Then Exit Sub
        If KeyAscii < vbKey0 Or KeyAscii > vbKey9 Then
            KeyAscii = 0
            Exit Sub
        End If
    End Sub
      

  2.   


    Private Sub txtInput_KeyDown(KeyCode As Integer, Shift As Integer)
        ' ************************************************
        ' * 限制只能输入数字
        ' ************************************************
         If KeyCode <> 46 and KeyCode<> vbKeyBack And KeyCode< Asc("0") Or KeyAscii > Asc("9") Then KeyCode= 0
    End Sub
      

  3.   

    Private Sub txtInput_KeyDown(KeyCode As Integer, Shift As Integer)
        ' ************************************************
        ' * 限制只能输入数字
        ' ************************************************
         If KeyCode <> 46 and KeyCode<> vbKeyBack And KeyCode< Asc("0") Or KeyCode > Asc("9") Then KeyCode= 0
    End Sub
      

  4.   

    Private Sub text1_KeyDown(KeyCode As Integer, Shift As Integer)
    if keycode<>48 and keycode<>49 and keycode<>50 and keycode<>51 and keycode<>52 and keycode<>53 and keycode<>54 and keycode<>55 and keycode<>56 and keycode<>57 and keycode<>13 and keycode<>8 then
     keycode=0
    end if 
    End Sub