If (KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii >= 97 And KeyAscii <= 122) Or KeyAscii = 8 Or KeyAscii = 13 Then
    Else
        MsgBox "请输入字符或数字!", vbInformation, "出错"
        KeyAscii = 0
    End If上面判断语句限制了以下几点:只能输入字符和数字(以及回车,退格)
但我不想屏蔽Ctrl_c(v),但不知道什么实现,请指教。

解决方案 »

  1.   

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
     Dim ctrldown
       ctrldown = (Shift And vbCtrlMask) > 0
     If (KeyCode >= 65 And KeyCode <= 90) Or (KeyCode >= 48 And KeyCode <= 57) Or ctrldown Or KeyCode = vbKeySpace Or KeyCode = vbKeyLeft Or KeyCode = vbKeyRight Or KeyCode = vbKeyBack Or KeyCode = vbKeyReturn Then Else
      MsgBox "请输入字符或数字!", vbInformation, "出错"
     End If
    End Sub基本满足你的要求,但对ctrl+v来的汉字没判断,自己可以添加