By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,837 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,837 IT Pros & Developers. It's quick & easy.

UDT Array in an array

P: n/a
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).ContainerNumber(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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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).containers(23).ContainerNumber = "A4K118171"
BL(4).containers(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
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Rowan" <ph********@yahoo.com> wrote in message
news:4b**************************@posting.google.c om...
: 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).ContainerNumber(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

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.