Results 1 to 4 of 4

Thread: Quick question about arrays

  1. #1

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668

    Quick question about arrays

    How do you make 2 dimsional arrays
    for example I'm making a mock store for my systems class and I want products to be under catagories so I have like a coleman 2-person tent under the catagory of Tents. I was trying to use something like

    Public Products(39,39) as string (I know hard code is bad but this program doesn't need to be scaleable)

    then
    Products(0) = "Tents"
    Products(0,0) = "Coleman 2-person tent"

    I get a compile error on the first

    Any help would be appriciated.
    If wishes were fishes we'd all cast nets.

  2. #2

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    hhmm maybe it would be better if I used a collection
    If wishes were fishes we'd all cast nets.

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Products(0, 0) = "Tents"
    Products(0, 1) = "Coleman 2-person tent"

    You can also create a User Defined Type
    Code:
    Option Explicit
    Private Type StockType
        strCategory As String
        strItem As String
    End Type
    
    Private Sub Form_Load()
    
        Dim Products(39) As StockType
        
        Products(0).strCategory = "Tents"
        Products(0).strItem = "Coleman 2-person tent"
        
        Products(1).strCategory = "Tents"
        Products(1).strItem = "Coleman 8-person tent"
        
        Products(1).strCategory = "Coolers"
        Products(1).strItem = "Mini"
        
    End Sub

  4. #4

    Thread Starter
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    Are you talking to me or martin, jason?

    That type idea is good thanks... whoever wrote it.
    If wishes were fishes we'd all cast nets.

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