本文转自:http://hi.baidu.com/ych0518/blog/item/b3b06559c429c5282834f0c5.html

Dim pd As Boolean

Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 And KeyAscii <> 8 Then
KeyAscii = 0
End If
If pd = True And KeyAscii = 46 Then
KeyAscii = 0
End If
If pd = False And KeyAscii = 46 Then
pd = True
KeyAscii = 46
End If
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
         '防止Ctrl + V 粘贴
     If KeyCode = vbKeyV And Shift = vbCtrlMask Then
         Text1.Enabled = False
         Clipboard.Clear
         Text1.Enabled = True
     End If
     '防止Shift Insert粘贴
If KeyCode = 45 And Shift = vbShiftMask Then
Text1.Enabled = False
Clipboard.Clear
Text1.Enabled = True
End If
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbRightButton Then
       Text1.Enabled = False
       Clipboard.Clear
       Text1.Enabled = True
    End If
End Sub

相关文章:

  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案