Retrieve Index by Values From an Array Through a ComboBox

十年热恋 提交于 2019-12-11 18:27:33

问题


I have a transposed dynamic n x 2 array that is used to populate a combobox. The primary column alone is not descriptive enough to identify rows uniquely. I would like to use the row index to identify the untransposed column uniquely. Using both columns in the array could also be used for this but may prove problematic down the line. This question is closely related to this question.

I have used Me.cbo.ListIndex = 0 to retrieve the index value. Ideally, I'd like to assign the index of the row chosen in the combobox to a variable. The ultimate goal is to use the index in two ways:

  1. For finding the correct column to use in future calculations
  2. As a method for comparison against another combobox that uses the same array in order to ensure that the same row has not been chosen in both comboboxes

To visually illustrate the above, the original data looks like this:

a  b  c  b
1  2  3  4
A  B  C  B

The transposed array looks like this:

A  1
B  2
C  3
B  4

I would like to be able to make a distinction between selecting B2 and B4, ideally by preserving and comparing index 1 and 3 respectively (0-based).

ListIndex is from the documentation. There is no documentation that I could find about retrieving the index from the name except where the value in the selection is unique. Any Help is greatly appreciated

来源:https://stackoverflow.com/questions/56042084/retrieve-index-by-values-from-an-array-through-a-combobox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!