Results 1 to 6 of 6

Thread: [RESOLVED] I need array help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    218

    Resolved [RESOLVED] I need array help

    I know I am going to have a hard time explaining.

    What I need is:

    Array of sDay()
    containing an array of sJob()
    containing an array of sSequence()
    with array of sSequence()
    containing a lStart and lFinish.

    sDay .LBound = 0, sDay UBound = 7 ' FIXED Array Size
    sJob LBound = 1 , sJob UBound = 8 ' FIXED Array Size
    sSequence LBound = 1, sSequnce UBound is ReDimable

    Then how to loop on all and get sSequence lStart and lFinish ?

    I tried a Type but my head started buzzing so I gave up.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    218

    Re: I need array help

    OMG, my brain fog is clearing.

    Will this work ?
    Private Type tSchStartStopType
    lStartTime As Long
    lStopTime As Long
    End Type
    Private Type tSchSequenceType
    atSequence() As tSchStartStopType
    End Type
    Private Type tSchJobType
    atJob(1 To 8) As tSchSequenceType
    End Type
    Private m_atDay(0 To 7) As tSchJobType

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,526

    Re: I need array help

    I'm not at all clear on what you want, but it sounds like UDTs might be the answer for you. UDTs give you an easy way to have nested arrays (nested to any level you want).

    Multi-dimension arrays is another option, but, the way you describe things, I'm not sure that'll do it for you.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,022

    Re: I need array help

    Something like this?

    Code:
    Private Type tSequence
        lStart  As Long
        lFinish As Long
    End Type
    
    Dim arr() As tSequence
    
    Private Sub Form_Load()
    Dim i As Long, j As Long, k As Long
        ReDim arr(0 To 7, 1 To 8, 0 To 0) As tSequence
        For i = LBound(arr, 1) To UBound(arr, 1)
            For j = LBound(arr, 2) To UBound(arr, 2)
                For k = LBound(arr, 3) To UBound(arr, 3)
                    ' assign values or whatever
                    Debug.Print arr(i, j, k).lStart, arr(i, j, k).lFinish
                Next k
            Next j
        Next i
        ReDim Preserve arr(0 To 7, 1 To 8, 0 To 1) As tSequence
        ' etc
    End Sub

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,526

    Re: I need array help

    Or, a combination of a UDT and a multi-dimension array.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    218

    Re: I need array help

    VanGoghGaming
    Thanks.
    I will try to incorporate that code.

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