Private Sub TextName_Change()
ListView1.ListItems.Clear
ss = "select * from 车辆维修 where 维修记录编号 like '%" + Trim(TextName.Text) + "%'"
adoRs.Open ss, cnn, adOpenKeyset, adLockOptimistic
For i = 0 To adoRs.RecordCount - 1
If Trim(adoRs.Fields("维修时间")) >= Text1.Text And Trim(adoRs.Fields("维修时间")) <= (Text2.Text + " 23:59:59") Then
Set mLItem = ListView1.ListItems.Add(, , Trim(adoRs.Fields("维修记录编号")))
With mLItem
.SubItems(1) = Trim(adoRs.Fields("车辆编号"))
.SubItems(2) = Trim(adoRs.Fields("维修时间"))
.SubItems(3) = Trim(adoRs.Fields("维修部件"))
.SubItems(4) = Trim(adoRs.Fields("维修费用"))
.SubItems(5) = Format(adoRs.Fields("维修结果"), "0.00")
End With
ListView1.SelectedItem.Selected = False
ListView1.ListItems.Item(1).Selected = True
ListView1.SelectedItem.EnsureVisible
End If
adoRs.MoveNext
Next i
adoRs.Close
End Sub
参考吧