aaronk Well-Known Member Licensed User Longtime User Aug 10, 2015 #1 Hi, I am trying to create a list but have multiple columns. I tried using a map (I might of done it wrong) but can't work out how to use multiple columns. I need to have the following fields in a list.. AccountID Field1 Field2 Field3 I want AccountID to be unique. So if the value of AccountID is already added in the list then it should not add the item to the list again. I need to be able to select Field1, Field2 & Field3 based on the accountID value. Any ideas on what I need to do to create a list based on the fields above ?
Hi, I am trying to create a list but have multiple columns. I tried using a map (I might of done it wrong) but can't work out how to use multiple columns. I need to have the following fields in a list.. AccountID Field1 Field2 Field3 I want AccountID to be unique. So if the value of AccountID is already added in the list then it should not add the item to the list again. I need to be able to select Field1, Field2 & Field3 based on the accountID value. Any ideas on what I need to do to create a list based on the fields above ?
Erel B4X founder Staff member Licensed User Longtime User Aug 10, 2015 #2 You can use a Map where the keys are the AccountID and the values are a custom type with all other fields. Upvote 0
You can use a Map where the keys are the AccountID and the values are a custom type with all other fields.
aaronk Well-Known Member Licensed User Longtime User Aug 10, 2015 #3 Are you able to give me a example ? I tried using the map but I could only work out how to add a key and only 1 value for that key. Upvote 0
Are you able to give me a example ? I tried using the map but I could only work out how to add a key and only 1 value for that key.
Erel B4X founder Staff member Licensed User Longtime User Aug 10, 2015 #4 Code: Copy Type MyDataType (AccountId As String, Field1 As String, Field2 As Int, Field3 As Double) Code: Copy Sub AddItemToMap(AccountId As String, Field1 As String, Field2 As Int, Field3 As Double) dim mt As MyDataType mt.Initialize mt.AccountId = AccountId mt.Field1 = Field1 ... map.Put(AccountId, mt) End Sub Code: Copy Dim mt As MyDataType = map.Get("Some Id") Upvote 0
Code: Copy Type MyDataType (AccountId As String, Field1 As String, Field2 As Int, Field3 As Double) Code: Copy Sub AddItemToMap(AccountId As String, Field1 As String, Field2 As Int, Field3 As Double) dim mt As MyDataType mt.Initialize mt.AccountId = AccountId mt.Field1 = Field1 ... map.Put(AccountId, mt) End Sub Code: Copy Dim mt As MyDataType = map.Get("Some Id")