组合框VB6中的唯一数据 [英] Unique data in combo box VB6
本文介绍了组合框VB6中的唯一数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下代码从访问组合框加载数据,但我想在组合框中只添加唯一数据(无重复项)。我正在使用DAO连接。
I am able to load the data from access to combo box with below code but I want to add only unique data (no duplicates ) in combo box. I am using DAO connection.
mySet.MoveFirst
While Not mySet.EOF
Combo1.List(I) = mySet.Fields(0)
mySet.MoveNext
I = I + 1
Wend
推荐答案
由于您使用的是数据库,因此修改查询以生成唯一值是有意义的。
如果以上选项不可行,则在添加新项目之前,您可以检查ComboBox中是否已存在具有相同文本的项目。
第三个选项是添加所有项目这些项目,对它们进行排序以及遍历ComboBox,删除具有相同文本的相邻项目。
Since you are using a database then makes sense to modify your query in order to produce only unique values.
If the above option is not feasible then, before adding a new item, you may check if there is already an item with the same text in the ComboBox.
A third option would be adding all the items, sorting them and the traversing the ComboBox removing adjacent items having the same text.
这篇关于组合框VB6中的唯一数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文