Private Sub datagrid1_KeyPress(Keycode As Integer)
If Keycode = 13 Then
If CInt(DataGrid1.Text) < 0 Or CInt(DataGrid1.Text) > 100 Then
MsgBox "数据输入出错¡"
Exit Sub
End If
DataGrid1.Row = DataGrid1.Row + 1
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If DataGrid1.Text < 0 Or DataGrid1.Text > 100 Then
MsgBox "数据输入有误!"
Exit Sub
End If
DataGrid1.Row = DataGrid1.Row + 1
DataGrid1.Col = 0
End If
End Sub
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If DataGrid1.Text < 0 Or DataGrid1.Text > 100 Then
MsgBox "数据输入有误!"
Exit Sub
End If
DataGrid1.Row = DataGrid1.Row + 1
End If
End Sub
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If Cint(datagrid1.text)>0 and Cint(datagrid2.text)<100 and keycode=vbKeyReturn Then
DataGrid1.Row = DataGrid1.Row + 1
DataGrid1.Col = DataGrid1.Col
End If
End Sub
dim gtext as string
gtext=..........'这行中的某数据
if Cint(gtext)>0 and Cint(gtext)<100 then
datagrid.row=datagrid.row+1
else
msgbox"您刚才输入的数据有误,请重新输入!",,"提示"
end if
Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
strOld = OldValue
End Sub
Private Sub DataGrid1_BeforeUpdate(Cancel As Integer)
If DataGrid1.Text < 0 Or DataGrid1.Text > 10 Then
MsgBox "数据非法~"
DataGrid1.Text = strOld
'Cancel = True
End If
End Sub