学生系统的各种限制

简介: 学生系统的各种限制

1.限制不准复制粘贴

Private Sub txtCourseno_KeyDown(KeyCode As Integer, Shift As Integer)

If Shift = 2 Then

MsgBox “不准复制粘贴”, vbOKOnly + vbExclamation, “提示”

End If

End Sub

Private Sub txtCourseno_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 2 Then MsgBox “不准粘贴复制”, vbOKOnly + vbExclamation, “警告”

End Sub

2.限制只能数字字母和退格键

Private Sub txtCourseno_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

3.限制特殊字符、数字、空格,只能输入汉字和字母

Private Sub txtDirector_KeyPress(KeyAscii As Integer)

Select Case KeyAscii

Case -20319 To -3652

Case 48 To 57

Case 65 To 90

Case 97 To 122

Case 8

Case Else

KeyAscii = 0

End Select

If KeyAscii < 0 Or KeyAscii = 8 Or KeyAscii = 13 Then

ElseIf Not Chr(KeyAscii) Like “[a-zA-Z]” Then

KeyAscii = 0

MsgBox “请输入汉字或字母”, vbOKOnly + vbExclamation, “提示”

End If

End Sub

4.只能输入数字字母汉字退格

Private Sub txtCoursename_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

'限制字数

If Len(txtCoursename) > 18 Then

KeyAscii = 0

MsgBox “字数超出”, vbOKOnly + vbExclamation, “提示”

End If

End Sub

5.添加成绩信息限制

Private Sub txtResult_Change()

On Error Resume Next

If Val(Trim(txtResult.Text)) > 150 Then

MsgBox “输入数字过大,请重新输入”, vbOKOnly + vbExclamation, “提示”

txtResult.Text = “”

End If

End Sub

6.限制家庭住址不能输入特殊字符

Private Sub txtAddress_KeyPress(KeyAscii As Integer)

Dim cTemp As String

cTemp = “`!@#$%^&*()-=_+[]{};:’|<>".‘“”’、,。——+()《》?,·……¥!:;【】” & “”" '禁止输入特殊的字符"

If InStr(1, cTemp, Chr(KeyAscii)) <> 0 Then

KeyAscii = 0

MsgBox “家庭住址不可为特殊字符”, vbOKOnly + vbExclamation, “提示”

End If

End Sub

相关文章
|
JavaScript 前端开发 Java
博客管理系统
博客管理系统
84 0
博客管理系统
|
Linux 芯片 C++
女朋友问我,系统咋装呀?
女朋友问我,系统咋装呀?
159 0
女朋友问我,系统咋装呀?
系统思考的介绍
3.3 系统思考的介绍 在控制理论中,分为开环控制系统和闭环控制系统。开环控制系统是不将控制的结果反馈回来影响当前控制的系统。闭环控制系统是将控制的结果反馈回来影响当前控制的系统。
976 0
|
监控 大数据 安全
系统思考
最近发现一本关于提高系统思维能力的书,是一本你读起来很容易接受,逻辑很清楚的书,下面我就总结下,给大家参考下 背景 一般在我们工作或者生活的过程中都会碰到下面三中情况 遇到事情突然想不清楚 表达时说不清楚 学习的时候学的慢 以上的场景可能不是所有人都遇到过,但这个不是最关键的。
1888 0
系统思考正反馈之马太效应
系统思考正反馈之马太效应 内容提要:马太效应是圣经力的一则寓言,用来阐述一旦获得一点优势,这个优势就会不断扩大,取得的成果也会越来越大,是一种正反馈现象。
1049 0
系统思考与《第五项修炼》
系统思考与《第五项修炼》——《可以量化的管理学》 内容提要:彼得•圣吉通过《第五项修炼》将控制理论的正反馈和负反馈引入管理学,对管理学理论产生了巨大的影响。
1278 0
|
测试技术 Python