Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

How can I work a collection based off of more than 1 member of a class?

$
0
0
I have a question!

I have a custom class -

Code:

Public Class Location
    Private m_Id As Integer
    Private m_Name As String

    Public Property Id As Integer
        Get
            Return m_Id
        End Get
        Set(ByVal value As Integer)
            m_Id = value
        End Set
    End Property

    Public Property Name As String
        Get
            Return m_Name
        End Get
        Set(ByVal value As String)
            m_Name = value
        End Set
    End Property
End Class

This class as you can see has both an Id and Name member. An example would be Name = "United States" Id = 0.

I have a combo box on my form, that I want to list the Name members in. So I will load a List (Of Location) into the combo box. A list of countries. However, the Id might not necessarily be numbered in any specific order. So when the person selects a country, I would like a currentLocation variable to be updated to that countries Id. How can I click on a country in the combo box and make sure, that at the same time, the currentLocation variable gets updated to that countries Id?

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>