【转】禁止vb文本框粘贴输入负数以及输入多个小数点

it2022-05-09  29

本文转自: 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

转载于:https://www.cnblogs.com/feima-lxl/archive/2008/05/03/1180500.html

相关资源:数据结构—成绩单生成器

最新回复(0)