學生系統優化——窗體限制

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

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

 

 

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