本文共 1122 字,大约阅读时间需要 3 分钟。
1.首先先去数据库将user PWD列的数据类型改为varchar(20),这样做的目的是将密码的后面的空格去掉。假如说不改数据类型,用户名与密码都是9的情况下,登录的时候“9+空格” 也可以登陆成功。
2.限制字符(字数、空格。我的理解密码可以是特殊字符,可以增强安全性。)
Private Sub txtPassword2_KeyPress(KeyAscii As Integer) '限制字数 If Len(txtPassword2.Text) > 10 Then KeyAscii = 0 MsgBox "字数超出 ", 64, "温馨提示:" txtPassword2.Text = "" End If '限制不可输入空格 If KeyAscii = 32 Then KeyAscii = 0 MsgBox "密码不可为空格 ", 64, "温馨提示:" txtPassword2.Text = "" End If End Sub
3.清空剪切板(当然也可以禁用右键,但是我总感觉得不偿失)
Private Sub txtPassword1_KeyDown(KeyCode As Integer, Shift As Integer) If Shift = 2 And KeyCode = vbKeyV Then '如果是Ctrl+V,清空剪贴板 Clipboard.Clear End IfEnd SubPrivate Sub txtPassword1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then '如果是右键,清空剪贴板 Clipboard.Clear End IfEnd Sub
这个小功能很简单,添加一个Label就行。
当窗体加载的时候
Label1.Caption = "等待查询"
当点击查询按钮的时候
Label1.Caption = "查询到" & mrc.RecordCount & "条记录"
我用的方法相当简单,一句代码即可:
Private Sub comOperator1_KeyPress(KeyAscii As Integer) KeyAscii = 0End Sub
转载地址:http://cqmxz.baihongyu.com/