Private Sub DGZCJ_KeyPress(KeyAscii As Integer) On Error Resume Next If dgZCJ.Col <> 2 Then Exit Sub If tpKCXX.bTJ Then Exit SubIf Not (KeyAscii = 13 Or KeyAscii = 8 Or KeyAscii = 46 Or KeyAscii > 47 And KeyAscii < 58) Then KeyAscii = 0 MsgBox "输入非法,请您输入数字", vbExclamation + vbOKOnly, "非法" Exit Sub End If If KeyAscii = 13 Then
If dgZCJ.Text < 0 Or dgZCJ.Text > 100 Then MsgBox "请输入0-100之间的成绩" Else dgZCJ.Row = dgZCJ.Row + 1 End If End If End Sub Private Sub DGzcj_RowColChange(LastRow As Variant, ByVal LastCol As Integer) If .. Then Exit Sub If dgZCJ.Col <> 2 Then dgZCJ.AllowUpdate = False Else dgZCJ.AllowUpdate = True End If End Sub
On Error Resume Next
If dgZCJ.Col <> 2 Then Exit Sub
If tpKCXX.bTJ Then Exit SubIf Not (KeyAscii = 13 Or KeyAscii = 8 Or KeyAscii = 46 Or KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = 0
MsgBox "输入非法,请您输入数字", vbExclamation + vbOKOnly, "非法"
Exit Sub
End If
If KeyAscii = 13 Then
If dgZCJ.Text < 0 Or dgZCJ.Text > 100 Then
MsgBox "请输入0-100之间的成绩"
Else
dgZCJ.Row = dgZCJ.Row + 1
End If
End If
End Sub
Private Sub DGzcj_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If .. Then Exit Sub
If dgZCJ.Col <> 2 Then
dgZCJ.AllowUpdate = False
Else
dgZCJ.AllowUpdate = True
End If
End Sub