VB中如何设置combobox下拉选项为不同
IfAdodc1.Recordset.RecordCount>0ThenOnErrorResumeNextAdodc1.Recordset.MoveFirstDoWhil...
If Adodc1.Recordset.RecordCount > 0 Then
On Error Resume Next
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
Combo1.AddItem Adodc1.Recordset.Fields("XXX")
Adodc1.Recordset.MoveNext
Loop
End If
表中XXX有很多条记录,如何在combobox下拉选项中只显示一条,多谢~! 展开
On Error Resume Next
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
Combo1.AddItem Adodc1.Recordset.Fields("XXX")
Adodc1.Recordset.MoveNext
Loop
End If
表中XXX有很多条记录,如何在combobox下拉选项中只显示一条,多谢~! 展开
1个回答
展开全部
If Adodc1.Recordset.RecordCount > 0 Then
On Error Resume Next
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
For i=0 To Combo1.ListCount - 1
If Combo1.List(i) = Adodc1.Recordset.Fields("XXX") Then Exit For
Next
If i = Combo1.ListCount Then Combo1.AddItem Adodc1.Recordset.Fields("XXX")
Adodc1.Recordset.MoveNext
Loop
End If
追问
这样是可以的,非常感谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询