学生系统优化——窗体限制

家庭住址不能输入特殊字符

Private Sub txtAddress_KeyPress(KeyAscii As Integer)
    Dim cTemp As String
    cTemp = "`~!@#$%^&*()-=_+[]{};:'\|<>/?.‘“”’、,。——+()《》?,~·……¥!:;【】" & """ '禁止输入特殊的字符"
    If InStr(1, cTemp, Chr(KeyAscii)) <> 0 Then
        KeyAscii = 0
    End If 
End Sub

姓名只能输入汉字

Private Sub txtName_keypress(KeyAscii As Integer)
    If KeyAscii >= -20319 And KeyAscii <= -3652 Or KeyAscii = 8 Then
    Else
        KeyAscii = 0
        MsgBox "请输入汉字!", vbOKOnly + vbExclamation, "提示"
        txtName.SetFocus
    End If 
End Sub

班号只能输入数字(无提示)

Private Sub comboclassno_KeyPress(KeyAscii As Integer)
    If KeyAscii < 7 Or KeyAscii > 9 And KeyAscii < 48 Or KeyAscii > 57 Then
        KeyAscii = 0
    End If
End Sub

学号文本框中只能输入数字(无提示)

Private Sub txtSID_keypress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57
        Case 8
    Case Else
        KeyAscii = 0
        MsgBox "请输入数字", vbOKOnly + vbExclamation, "提示"
        txtSID.Text = ""
    End Select
End Sub

入学日期不能大于出生日期的代码

Private Sub DTPBorndate_change()
    If DTPBornDate.Value >= DTPRudate.Value Then
        MsgBox "入学日期大于出生日期,请重新选择!", vbOKOnly + vbExclamation, "提示"
        DTPBornDate.SetFocus
    End If
End Sub

Private Sub DTPRudate_change()
    If DTPRudate.Value <= DTPBornDate.Value Then
        MsgBox "入学日期大于出生日期,请重新选择!", vbOKOnly + vbExclamation, "提示"
        DTPRudate.SetFocus
    End If 
End Sub

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章