View Full Version : Putting data into two dimensional array

10-13-2003, 05:43 PM
I have this kind of data:

I want to put it into two dimensions array, because I want to display it in a table for each column (like: "name1,sex1,age1").

How can I put it all in one array?

10-13-2003, 06:32 PM
with .NET you could do a

class Person

and a collection of this class

better than arrays

10-13-2003, 08:42 PM
I know nothing about .NET :(
Isn't there a way to join this into one, two-dimensional array?

10-14-2003, 05:39 AM
no array in that case, you need a collection specialized (of persons)

Imports System.Collections

Public Class Person
Private Name as String
Private Sex as Boolean ' if you use only 2 sex :-)
Private Age as Byte
End Class

Public Class PersonCollection : : Inherits CollectionBase

Public Function Add(ByVal item As Person) As Integer
Return InnerList.Add(item)
End Function

Public Sub Remove(ByVal item As Person)
End Sub

Default Public Property Item(ByVal index As Integer) As Person
Return CType(InnerList(index), Person)
End Get
Set(ByVal Value As Person)
InnerList(index) = Value
End Set
End Property

End Class


then to use it :

Private _P As Person
Private _PC As New PersonCollection()

_P.Name = "ShMiL"
_P.Age = 30
_P.sex = True


or a shortcut like :


then the first Row of Your _PC has one Person with 3 values :
ShMiL 30 Man

of Course it is a very simple example, you can do a lot in that way, onlworking with a Type = Person