Home > OS >  How can I achieve a searchable data structure in VB.NET/WinForms? (Core 3.1)
How can I achieve a searchable data structure in VB.NET/WinForms? (Core 3.1)

Time:09-16

Sorry for my bad explaination in advance.

So I have the following situation: I got a forms app I am creating. I am pretty new to vb.net, but worked to some degree with Excel VBA.

I want to have a dropdown field with a list of countries, all tied to a number which can appear multiple times, for ex.

Germany -> 1
Netherlands -> 2
Belgium -> 2

Now, based on the selection of the user of this planned form I want to get the corresponding Number to calculate/use further on.

First question: How can I store the data the best, and how do I get the right number when processing?

CodePudding user response:

Probably use a Dictionary(Of String, Integer). The country names are the keys and the numbers are the values. You can even bind it to a ComboBox and display the keys, then get the corresponding value from the SelectedValue property.

  • Related