1、输入姓名的文本框只能输入汉字和字母(考虑到英语外教老师)
Private Sub txtDirector_KeyPress(KeyAscii As Integer)
If KeyAscii >= -20319 And KeyAscii <= -3652 Or KeyAscii = 8 Or (KeyAscii > 65 And KeyAscii < 90) Or (KeyAscii > 97 And KeyAscii < 122) Then
Else
KeyAscii = 0
End If
End Sub
2、输入学号班号的文本框只能输入数字
Private Sub txtClassno_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub
3、用户名只能输入数字、字母、汉字
Private Sub txtUserName_KeyPress(KeyAscii As Integer)
If KeyAscii >= -20319 And KeyAscii <= -3652 Or KeyAscii = 8 Then
ElseIf KeyAscii < 48 Or (KeyAscii > 57 And KeyAscii < 64) Or (KeyAscii > 91 And KeyAscii < 96) Or KeyAscii > 122 Then KeyAscii = 0
End If
End Sub
4、密码只能输入数字、字母
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
ElseIf KeyAscii < 48 Or (KeyAscii > 57 And KeyAscii < 64) Or (KeyAscii > 91 And KeyAscii < 96) Or KeyAscii > 122 Then KeyAscii = 0
End If
End Sub
5、课程名称只能输入汉字
Private Sub txtCoursename_KeyPress(KeyAscii As Integer)
If KeyAscii >= -20319 And KeyAscii <= -3652 Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub
6、再次输入密码不能复制粘贴
Private Sub txtUserName_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = MouseButtonConstants.vbRightButton Then
End If
End Sub
7、文本框限制字符长度
MaxLength 控件属性
8、确认添加快捷键 Default属性改为True;取消添加 Cancel 属性改为 True
9、下拉框禁止输入
Private Sub comboGrade_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
10、每次添加完再添加要清空内容 .text="" 或 .clear
11、添加成绩要合理
If Trim(txtResult.Text) > 150 Or Trim(txtResult.Text) < 0 Then
MsgBox "数值不在范围内,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtResult.Text = ""
txtResult.SetFocus
Exit Sub
End If
12、联系电话只能输入11位,控件属性 MaxLength改,数据库字符类型也需要改
13、日期控件改成DTPicker
14、查询信息时姓名、学号等显示在表格的第一行
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "性别"
15、显示查询到几条记录
n = 0
n = n + 1
Loop
Label1.Caption = "共查询到" & n & "条记录"
16、修改密码时显示当前用户
name = Trim(mrc.Fields(0))
Label4.Caption = "当前用户名为:" & name
17、窗体居中显示
Me.Left = (frmMain.Width - Me.Width) / 2
Me.Top = (frmMain.Height - Me.Height) / 2
Me.Width = 8325
Me.Height = 6060
18、选中复选框时对应的文本框才有效
Private Sub check1_Click()
Dim a As Long
a = Check1.Value
If a = 1 Then
txtSID.Text = ""
txtSID.Enabled = True
Else
txtSID.Text = ""
txtSID.Enabled = False
End If
End Sub
19、修改密码后要重新进入系统
20、删除所有信息后3021错误 用GOTO语句