Solved

# array

Posted on 2006-06-04
207 Views
Last Modified: 2010-04-23
folks

i need help on a simple array

month   rent        car house    total
jan         100      100  2000     2200
feb           200    100  1800      2100

total         300     200  3800      4300

how do i set this up

0
Question by:rutgermons
4 Comments

LVL 85

Expert Comment

So you want a two dimensional array with this data in it?  Where is the data coming from though?

Will there already be an empty row/col in the array where we will put the totals?

A little more info please...there may be a better approach.  =)
0

LVL 96

Expert Comment

DataTable?

Bob
0

LVL 10

Accepted Solution

You can use DataTable as suggest by Bob or Generic type (Framework 2.0)

' Generic Type Sample

Public Structure Spend

Public Rent As Single
Public Car As Single
Public House As Single

Public ReadOnly Property Total()
Get
Return Rent + Car + House
End Get
End Property

End Structure

Private _Account As New Dictionary(Of String, Spend)        <--- generic type instead of array

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' Add Data
Dim monthlySpend As Spend

With monthlySpend
.Rent = 100
.Car = 100
.House = 2000
End With
_Account.Add("jan", monthlySpend)

With monthlySpend
.Rent = 200
.Car = 100
.House = 1800
End With
_Account.Add("feb", monthlySpend)

' Retrieve data
Dim rentTotal As Single = _Account("jan").Rent + _Account("feb").Rent
Dim carTotal As Single = _Account("jan").Car + _Account("feb").Car
Dim houseTotal As Single = _Account("jan").House + _Account("feb").House
Dim grandTotal As Single = _Account("jan").Total + _Account("feb").Total

End Sub
0

LVL 1

Expert Comment

i persume that it is for display

1. inherit the windows form datagrid to accomodate sub total fields
both horizontally and vertically.
2. create and add datatable to a dataset
3. create and add datarow to the datatable
populate fields in the data row
u can give column headers for datatable

need more help? (about datagrid inheritance)
0

## Write Comment

Please enter a first name

Please enter a last name

We will never share this with anyone.

## Featured Post

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

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

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

#### Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!