读书人

能否对上面的代码优化一上

发布时间: 2012-09-11 10:49:03 作者: rapoo

能否对下面的代码优化一下

VB code
Private Sub Command4_Click() '删除本条记录If Adodc3.Recordset.RecordCount = 0 Then Exit Sub '记录表中无记录时,如果要删除,就立即退出Adodc3.Recordset.DeleteIf Adodc3.Recordset.RecordCount = 0 Then Exit Sub '删除了最后一条记录则退出Adodc3.Recordset.MoveNextEnd Sub


[解决办法]
这样好点
VB code
Private Sub Command4_Click() '删除本条记录    On Error Resume Next    If Adodc1.Recordset.EOF Then Exit Sub    Adodc3.Recordset.Delete    If Err.Number <> 0 Then Err.Clear: Exit Sub    Adodc3.Recordset.MoveNext    If Err.Number <> 0 Then Err.ClearEnd Sub 

读书人网 >VB

热点推荐