"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>>>>> is there a way to store the TotalGross and use that for a calculation
>>>>> within the foreach {} loop for the dsExpense so I can have the net
>>>>> calculated?
>>>>
>>>> Can't you just declare a module-level variable and increment it as
>>>> required...?
>>>
>>>I have something like that and its only storing the last value, I need
>>>all values for each year
>>
>> Are you overwriting the class-level variable each time rather than
>> incrementing it...?
>
> I was trying to increment it but it was only storing the last year's
> value.
> I was trying this on Saturday actually and I deleted the code, so I can't
> show you what I had either to help out.
If you need to store individual values per year, then you could use a
generic e.g.
Dictionary<int, decimal> dicTotals = new Dictionary<int, decimal>();
Then, within your foreach loop:
if (!dicTotals.Contains(2004)
{
dicTotals.Add(2004, MyRunningTotal);
}
else
{
dicTotals[2004] += MyRunningTotal;
}
N.B. the above is probably not particularly efficient, but should work...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net