来个例子。你稍微改一下就能用。
Dim Row As Long
Dim tmpI As Long
Dim MaxRow As Long
Dim tmpID As String
MaxRow = fg.SelectedRows
If fg.Row > 0 And MaxRow > 0 Then
If MsgBox("是否永久删除这些记录?" & vbCrLf & "注意:这些记录被删除后将不可恢复!", vbQuestion + vbYesNo + vbDefaultButton2, "提示") = vbYes Then
For tmpI = 1 To MaxRow
Row = fg.SelectedRow(0)
tmpID = fg.TextMatrix(Row, fg.ColIndex("ID"))
If tmpID <> "" Then
fg.RemoveItem Row
cn.Execute "delete from tb where id=" & tmpid
End If
Next tmpI
End If
End If
Dim i,j
With vfg
For i = IIf(.Row < .RowSel, .Row, .RowSel) To IIf(.Row > .RowSel, .Row, .RowSel)
j = .TextMatrix(i, 1)
cn.Execute "delete from tb where id='" & j & "'"
Next i
End With