UDT Array in an array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rowan

    #1

    UDT Array in an array

    Greetings:

    I need some guidance. I have been using UDT's and arrays to hold
    information so I can easily display data and save it. I am in the
    process of building a new form and ran across a problem I can't figure
    out how to solve.

    I have a UDT as follows:

    Public Type udtBL
    scac As String * 4
    BL As String * 12
    GrossWt As Double
    GW_UOM As String * 1
    PcCt As Double
    PC_UOM As String * 4
    po_id() As Long
    po() As String * 20
    Status() As String * 2
    ContainerNumber () As String * 11
    SealNumber() As String * 20
    TypeID() As Integer
    ContGW() As Double
    ContGW_UOM() As String * 1
    contPC() As Double
    ContPC_UOM() As String * 4
    ContVol() As Double
    ContVol_UOM() As String * 4
    End Type

    In my form I do the following

    Option Explicit
    Dim BL() As udtBL

    Private Sub Form_Load()
    Redim BL(1 to 100)
    '-----Then I load it using the syntax BL(i).Container Number(x) =
    "Container1 "
    End Sub


    This is all fine and dandy, but in this particular form, the Container
    has multiple PO numbers I want to load as well. I have no idea how to
    do this.

    So i have my BL(1).BL = "BL1"
    my BL(1).Container (1) = "Container1 "
    But then Container1 has two Purchase Orders that go with it...PO1 and
    PO2.

    How can I store the Purchase Orders for that container?

    I would think it should be BL(1).Container (1).PO(1)

    Can I do this? If so, what is the syntax? Is there a better, more
    efficient way to deal with this? I am very comfortable with arrays.

    I would really appreciate any help.

    --rowan
  • Randy Birch

    #2
    Re: UDT Array in an array

    Personally ... and this would necessitate a re-write of the app ... I would
    group related array-type Type members into their own UDTs, and include those
    in the final UDT. For example, air code based on what appears related in
    your app:

    Private Type POItems
    po_id As Long
    po As String * 20
    status As String * 2
    End Type

    Private Type ContainerItems
    Container as <whatever>
    ContainerNumber As String * 11
    End Type

    Private Type udtBL
    <your other members>
    podata() as POItems
    containers() as ContainerItems
    End Type

    .... then use appropriately ...

    dim BL() as udtBL
    Redim BL(1 to 100) as udtBL ... etc etc

    BL(4).container s(23).Container Number = "A4K118171"
    BL(4).container s(23).container = "Container1 "
    BL(4).podata(23 ).po_id = 12345
    BL(4).podata(23 ).po = "HWK 113-131"
    .... etc.

    This way you can increase the number of containers or POs easily with one
    redim.



    --

    Randy Birch
    MVP Visual Basic

    Please respond only to the newsgroups so all can benefit.


    "Rowan" <phantomtoe@yah oo.com> wrote in message
    news:4bbf8d70.0 406081402.799cf 2c2@posting.goo gle.com...
    : Greetings:
    :
    : I need some guidance. I have been using UDT's and arrays to hold
    : information so I can easily display data and save it. I am in the
    : process of building a new form and ran across a problem I can't figure
    : out how to solve.
    :
    : I have a UDT as follows:
    :
    : Public Type udtBL
    : scac As String * 4
    : BL As String * 12
    : GrossWt As Double
    : GW_UOM As String * 1
    : PcCt As Double
    : PC_UOM As String * 4
    : po_id() As Long
    : po() As String * 20
    : Status() As String * 2
    : ContainerNumber () As String * 11
    : SealNumber() As String * 20
    : TypeID() As Integer
    : ContGW() As Double
    : ContGW_UOM() As String * 1
    : contPC() As Double
    : ContPC_UOM() As String * 4
    : ContVol() As Double
    : ContVol_UOM() As String * 4
    : End Type
    :
    : In my form I do the following
    :
    : Option Explicit
    : Dim BL() As udtBL
    :
    : Private Sub Form_Load()
    : Redim BL(1 to 100)
    : '-----Then I load it using the syntax BL(i).Container Number(x) =
    : "Container1 "
    : End Sub
    :
    :
    : This is all fine and dandy, but in this particular form, the Container
    : has multiple PO numbers I want to load as well. I have no idea how to
    : do this.
    :
    : So i have my BL(1).BL = "BL1"
    : my BL(1).Container (1) = "Container1 "
    : But then Container1 has two Purchase Orders that go with it...PO1 and
    : PO2.
    :
    : How can I store the Purchase Orders for that container?
    :
    : I would think it should be BL(1).Container (1).PO(1)
    :
    : Can I do this? If so, what is the syntax? Is there a better, more
    : efficient way to deal with this? I am very comfortable with arrays.
    :
    : I would really appreciate any help.
    :
    : --rowan

    Comment

    Working...