Solved

VB.NET Multidimensional Array

Posted on 2013-06-30
2
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pressing download button in c# 7 36
Coding for the first time 9 70
vb.net datagrid scroll automatically to the first found row 11 28
Stop Git from being my repository 1 26
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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