Solved

# array

Posted on 2006-06-04
Medium Priority
221 Views
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

LVL 86

Expert Comment

ID: 16828582
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?

0

LVL 96

Expert Comment

ID: 16829363
DataTable?

Bob
0

LVL 10

Accepted Solution

ericwong27 earned 2000 total points
ID: 16830066

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

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

Dim monthlySpend As Spend

With monthlySpend
.Rent = 100
.Car = 100
.House = 2000
End With

With monthlySpend
.Rent = 200
.Car = 100
.House = 1800
End With

' 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

ID: 16841583
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

## Featured Post

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
###### Suggested Courses
Course of the Month14 days, 7 hours left to enroll