我想使用VB6内存中的数据结构(Array?Collection?Whatelse?),它将启用两个标准的搜索。
例如:
Fruit_structure
- key1 (non-unique)
- key2 (non-unique)
- data1
- data2
- data3
伪代码:
- Lookup [Fruit_structure] where key1 = "Lemon" and key2 = "Volkamer"
- if found a = data1, b = data2, c = data3
如果您可以发布样本来加载和检索数据,那就太棒了
答案 0 :(得分:0)
你的意思是这样吗?
Private Type dataHolder
Key1 As String
Key2 As String
Data1 As String
End Type
Dim myDict(1 To 10) As dataHolder
Private Sub Command1_Click()
myDict(1).Key1 = "aaa"
myDict(1).Key2 = "bbb"
myDict(1).Data1 = "entry 1"
myDict(2).Key1 = "xxx"
myDict(2).Key2 = "zzz"
myDict(2).Data1 = "entry 2"
myDict(3).Key1 = "kkk"
myDict(3).Key2 = "qqq"
myDict(3).Data1 = "entry 3"
myDict(4).Key1 = "eee"
myDict(4).Key2 = "rrr"
myDict(4).Data1 = "entry 4"
Dim result As dataHolder
result = GetValue("kkk", "qqq")
MsgBox result.Data1
End Sub
Private Function GetValue(Key1 As String, Key2 As String) As dataHolder
Dim x As Variant
Dim i As Integer
For i = LBound(myDict) To UBound(myDict)
If myDict(i).Key1 = Key1 And myDict(i).Key2 = Key2 Then
GetValue = myDict(i)
Exit Function
End If
Next i
End Function