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
Solved

Array of a specific type

Posted on 2006-10-21
1
180 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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