Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Putting data into two domensions array

    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

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    with

    with .NET you could do a

    class Person

    and a collection of this class

    better than arrays

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I know nothing about .NET
    Isn't there a way to join this into one, two-dimensional array?

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    no array

    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
    Last edited by angiras; 10-14-2003 at 06:48 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •