Solved

Array of a specific type

Posted on 2006-10-21
1
184 Views
Last Modified: 2010-04-23
Hello experts,

I am making an application that receives various blocks of information from a server application.  One type of information that my application will need to receive, process and display (in a list box) is the name of other users who are connected to the server.

The information is sent to my application through a socket connection and blocks of data are sent as applicable....as in if someone new connects then a new block with those details is sent.  

So I know I need to use an array of some kind in order to store this information.  At first the array will be empty because the application needs to receive a data block with a new user's details.  So lets say the application gets a new user....I will clearly need to redim the array (preserving current data) to enable me to add the new data block.  That's fine and easy - no problems.  The datablock contains the user's name and their connected name (callsign if you will).  Once I have this information my program requests more information and this is sent in a different datablock.  In total the information I need to store, for each user, is:

* Callsign
* Name
* Frequency
* Rating
* Sector File

All the above are string values.  

Now my question is how do I store that specific information in an array?  I could define a user type but how do I get that to work with the array?  I want to be able to display the data in the array on a column based list box if applicable.  I also need to be able to easily remove users from the array (by callsign) if they disconnect.

Any help on how I can best achieve the above would be much appreciated.

Regards,

Ady
0
Comment
Question by:Ady Foot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 29

Accepted Solution

by:
Nightman earned 500 total points
ID: 17781444
Why not work with a class (i.e. user class) and collection.

Public NotInheritable Class User
  Private m_name As String
  Private m_callsign As String
  Private m_frequency As String
  Private m_rating As String
  Private m_sectorFile As String

  Public Sub New(ByVal Name As String)
    m_name = Name
  End Sub

  Public Property Callsign() As String
    Get
      Return m_callsign
    End Get
    Set(ByVal Value As String)
      If m_callsign <> Value Then
        m_callsign = Value
      End If
    End Set
  End Property

  Public ReadOnly Property Name() As String
    Get
      Return m_name
    End Get
  End Property
End Class

Then you create a collection of users
Dim oUser As User
Dim oCol As Collection
oCol = New Collection
oUser = New User("afoot")
oCol.Add(oUser, oUser.Name)

'To Update a setting
oCol.Item("afoot").Callsign = "test"

'To Test that your value has been set correctly
Dim xCallsign As String = oCol.Item("afoot").Callsign
'To Remove
oCol.Remove("afoot")

This is definitely easier to work with. I have only provided the Constructor, the Name Property (readonly) and the Callsign Property - you could easily fill in the rest
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question