[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Array of a specific type

Posted on 2006-10-21
1
Medium Priority
?
188 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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