我有一个包含 CSV 信息的文本文件。我希望每个条目中的单个字段来填充组合框。但是当用户从组合框中选择一个项目时,我想保留与其他数据的关系。
例如:
Dim c as Collection
c = ReadFile() 'returns a Collection of variant arrays to c
Dim info As Variant
For Each info In c
'Let's say, for example, info(3) contains the human-friendly name of the item
'(which may or may not be unique)
'and info(0) contains the unique ID of the item (which I need to reference later)
'I'd like to put:
'combobox.AddItem(info)
'but I'm getting errors unless I do something more specific, like:
combobox.AddItem (info(3))
'Can I preserve each info() object as a part of the combobox?
'I know this can be done in .NET but I'm not so sure about VBA.
Next info
是否可以将我的“信息”集合存储在组合框中?
稍后在代码中,我希望使用以下内容的便利:
combobox.SelectedItem(0)
或者
combobox.Value(0)
检索我的唯一 ID。