Solved

VB.NET Multidimensional Array

Posted on 2013-06-30
2
462 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Keyboard 2 35
SQL LINE CONTINUATION ISSUE 12 34
get column names from table in vb.net 8 31
VB.net and sql server 4 36
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 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