仅使用combobox(范围)中的选定值执行重复任务

我有一个combobox从Access数据库表中填充整数值。 这个表通常列出值(1,2,3,4,5,6,7,8,9,10等等),但是例如如果用户已经删除了之间的任何值,则combobox值可能看起来像(1,3,4,6,7,8,10)。 我执行导出Excel工作簿与基于每个值的工作表名称。 如果我有缺less的值,在我的For – Next循环中,程序在1之后卡住。它不会跳到值3.是否有可能在这种情况下获取Combobox中可用值的列表,然后仅对这些有效的可用值执行导出?

更新:解决Viktor的帮助…

For Each item As Object In ComboBox1.Items Dim drv As DataRowView = item 'ComboBox1.SelectedItem Dim value As Integer = drv("Unique_ID").ToString 'StartNo and EndNo specify the range If (value >= StartNo) And (value <= EndNo) Then ComboBox1.SelectedValue = value xlWorkSheet.Name = ("EmpNo_" & value) ' do the export task end if Next 

这似乎工作:

 For Each item As Object In ComboBox1 'Value will hold the value of the item, eg 1,3,4,6,7,8,10 'To compare it we will convert the item to a Single type (a number) using CSng() Dim value As Single = CSng(item.ToString) 'Export if values are between 4 and 10 If (value > 4) and (value < 10) Then 'Export /.../ End If Next