Solved

VB.NET Multidimensional Array

Posted on 2013-06-30
2
457 Views
Last Modified: 2013-06-30
I need to create a list or array that would hold the below values.

Item                          Total               Amount
Item 01                        3                     $595
Item 02                        3                     $695

Also, need to know how you would get the values from the array.

Thanks
0
Comment
Question by:CipherIS
2 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 39288322
I would create a user-defined class (ItemDetail), create instances of that class for each entry, and the create a List of those instances, identified by the Item (Item 01, Item 02, etc.)

AW
0
 
LVL 12

Accepted Solution

by:
funwithdotnet earned 500 total points
ID: 39288326
I think the best way is to create a class that has the properties you want.

You might try something like:
Public Class ItemList

Public Property ItemName as String
Public Property ItemTotal as Integer
Public Property ItemAmount as Decimal

Public Sub New ()
End Sub

Public Sub New (myItemName as String, myItemTotal as Integer, myItemAmount as Decimal)
ItemName = myItemName
ItemTotal  = myItemTotal 
ItemAmount = myItemAmount  
End Sub

End Class

Open in new window


Now you can create a collection to hold your ItemList objects

Dim myCollection as New Collection
Dim tempItemList as ItemList

tempItemList = new ItemList("Item 01", 3, 595.00)            
myCollection.Add(tempItemList,("Item 01")
' repeat as necessary ...
tempItemList = new ItemList("Item 02", 3, 695.00)            
myCollection.Add(tempItemList,("Item 02")

Open in new window


It is easy loop thru the collection or retrieve an ItemList object by key ( i.e."Item 01")

Each ItemList object has the properties you want.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Latency in .net app using DB in .net 21 37
detecting  the added row index in a datagridview 3 62
Turn on intranet settings 1 42
C# parent child form 5 20
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now