Hi there,
I have the following class
When I add instances of this class to a ListBox, I'd like the ListBox to print the "_realmname" attribute, sort of like the way you have the toString() function for Java (iirc).Code:Public Class Server Private _realmname As String Private _isEU As Boolean Private _isUS As Boolean Private _isUp As Boolean Private _type As String Private _population As String ' Method to set/get the realm name, eg Stormrage Public Property RealmName() Get Return _realmname End Get Set(ByVal value) _realmname = value End Set End Property ' Method to set/get whether the realm is hosted in Europe Public Property isEU() Get Return _isEU End Get Set(ByVal value) _isEU = value _isUS = Not value End Set End Property ' Method to set/get whether the realm is hosted in the US Public Property isUp() Get Return _isUp End Get Set(ByVal value) _isUp = value End Set End Property ' Method to set/get what kind of realm this is, eg PvP, RP, Normal, RPPVP Public Property Type() Get Return _type End Get Set(ByVal value) _type = value End Set End Property ' Method to set/get the population load on the server, eg New, Full, Medium Public Property Population() Get Return _population End Get Set(ByVal value) _population = value End Set End Property End Class
Example, I have a listbox named ListBox_AllServers, now when I add a Server instance with _realmname set to "Stormrage", I'd like the following code
To result in the name "Stormrage" appearing in the listbox.Code:Dim StormrageServerObj as Server StormrageServerObj.RealmName = "Stormrage" ListBox_AllServers.Items.Add(StormrageServerObj)
What function do I need to implement in my Server class to make this happen?
Thanks in advance.
Mightor




Reply With Quote