Solved

VB.NET Multidimensional Array

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

13 Experts available now in Live!

Get 1:1 Help Now