Data structures VB6数据结构执行两个条件搜索
我想使用VB6内存数据结构数组?收集什么?这将启用具有两个条件的搜索 例如:Data structures VB6数据结构执行两个条件搜索,data-structures,vb6,Data Structures,Vb6,我想使用VB6内存数据结构数组?收集什么?这将启用具有两个条件的搜索 例如: 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 如果你能发布一个示例来
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
如果你能发布一个示例来加载和检索数据,那就太好了。你是说这样的吗
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
如果有4个数据字段呢?Ie data1、data2、data3、data4…结果将包含一个逗号分隔的值?啊,好的,我没有看到函数。现在我明白了。我只需要修改Getvalue和数据结构。它不会闪电般的快,但它应该能工作。谢谢