...

View Full Version : Putting data into two dimensional array



ShMiL
10-13-2003, 05:43 PM
I have this kind of data:
"name1,name2,name3...nameN"
"sex1,sex2,sex3...sexN"
"age1,age2,age3...ageN"

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?
Thanks

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

class Person

and a collection of this class

better than arrays

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

angiras
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)
InnerList.Remove(item)
End Sub

Default Public Property Item(ByVal index As Integer) As Person
Get
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

_PC.Add(_P)


or a shortcut like :

_PC.Add(_P("ShMiL",30,True))
_PC.Add(_P("Jenny",20,False))
ect....


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum