- 查询窗体复选框优化
复选框取消勾选之后文本框中的内容和查询的内容也被清空
'Check√取消后面的内容随之取消
Private Sub Check1_Click()
If Not Check1.Value Then
txtSID.Text = “”
With myFlexgrid
.Rows = 2
.CellAlignment = 4
.TextMatrix(1, 0) = “”
.TextMatrix(1, 1) = “”
.TextMatrix(1, 2) = “”
.TextMatrix(1, 3) = “”
.TextMatrix(1, 4) = “”
.TextMatrix(1, 5) = “”
.TextMatrix(1, 6) = “”
.TextMatrix(1, 7) = “”
End With
End If
End Sub - 文本框加限制
一、限制只能输入数字
Private Sub txtsid_KeyPress(keyascii As Integer)
If keyascii >= 33 Then
If keyascii <= vbKey9 And keyascii >= vbKey0 Then
Else
keyascii = 0
MsgBox “请输入数字!”
End If
End If
End Sub
二、限制不能输入数字
Private Sub Txtname_KeyPress(keyascii As Integer) '姓名不能输入数字
If (keyascii >= 48 And keyascii <= 57) Then
MsgBox “不允许输入数字”, vbOKOnly + vbExclamation, “警告”
keyascii = 0 '键盘不能用
End If
End Sub
三、限制姓名字数
'设置姓名字节的限制,由2个到4个字组成,即4-8个字节组成
Private Sub txtdirector_LostFocus()
If Not LenB(txtDirector) = 0 And LenB(txtDirector) < 4 Or LenB(txtDirector) > 8 Then
txtDirector.SetFocus
txtDirector.SelLength = Len(txtDirector.Text)
txtDirector.SelStart = 0
MsgBox “姓名输入错误”
End If
End Sub
四、下拉框禁止输入
Private Sub comboclassno_keypress(keyascii As Integer)
keyascii = 0
End Sub
学生信息管理系统之优化二
最新推荐文章于 2020-12-26 17:11:57 发布