Results 1 to 7 of 7

Thread: What data type to use?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    What data type to use?

    Hey,

    I want to creat such items collection (like table):

    On item consist such data:

    Name (String), Type (String), Validation (String), Order (Integer), Emails (Elements list, array os smth)

    What data types to uses, how to write such collection?

    Thanx

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Use a structure or a class.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    Can you give me an example?

    What data type to use when storing strings list?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    I tried to use structure, but it is not what I need.

    I need something like table:

    Every item must consist Name (String), Type (String), Validation (String), Order (Integer). What data type to use and how to use it?

    Emails I can store seperatly in arraylist.

  5. #5
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    I'm sorry, but could you explain why a structure is not suitable for your needs?
    If you create a structure, and then create items of that structure type, you can add the new items to an arraylist.

    Perhaps I am just not understanding what you need, but based on your explanation and my experience, a structure should work perfectly.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    Can you give me an exampe?

    There would be more then one item (row) in this array:


    I need something like this to use:

    dim myList as MuCustomArrayList

    myList.Add(Name1, Type1, Validation1, Order1)
    myList.Add(Name2, Type2, Validation2, Order2)
    myList.Add(Name3, Type3, Validation3, Order3)

    To read 1rs item's order:

    Response.write Ctype(myList(1).Items(4).Value, Integer)

  7. #7
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Ok, try this:
    VB Code:
    1. ' Declarations Section
    2.     Public Structure myListItem
    3.         Public Name As String
    4.         Public Type As String
    5.         Public Validation As String
    6.         Public Order As Int32
    7.     End Structure
    8.     Private myItemsList As ArrayList = New ArrayList
    9.  
    10.     ' New Sub to add and get the Items, you probably want to use separate subroutines for this.
    11.     Private Sub GetMyItemOrder()
    12.         Dim myItem As myListItem
    13.         Dim Items As Int32
    14.         For Items = 0 To 4
    15.             myItem.Name = "User" + Items.ToString
    16.             myItem.Type = "Type" + Items.ToString
    17.             myItem.Validation = ">0"
    18.             myItem.Order = Items
    19.             myItemsList.Add(myItem)
    20.         Next
    21.         myItem = myItemsList(1)
    22.         Me.TextBox1.Text = myItem.Order.ToString
    23.     End Sub

    Hope this helps you.

Posting Permissions

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



Click Here to Expand Forum to Full Width