Re: This is EASILY done in Excel:

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Aaron (aaron_at_jonharvey.com)
Date: 08/17/04


Date: Tue, 17 Aug 2004 15:33:55 +0100

I use this site to translate C# into VB.NET

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

"Coleen" <coleenholley@yaho.com> wrote in message
news:ebdJBLHhEHA.2908@TK2MSFTNGP10.phx.gbl...
> Hi Alvin, and Thanks :-)
>
> I could really use some help here. I don't know C# and I am having
trouble
> deciphering your code into VB. Would it be possible for you to give me an
> example in VB? I can NOT get this to work, and I have spent 4 days on
it!!!
> This is ridiculous! I would REALLY appreciate ANY help that you or anyone
> else can give. We are using VB.Net in a Web form, with an aspx.net
> datagrid.
>
> TIA
>
> Coleen
>
> "This is EASILY done in Excel:
> and it is EASIER in .net"
>
> in your itemdatabound event handler
>
> if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> ListItemType.AlternatingItem)
> {
> int total = Int32.Parse( ds.Tables[0].Compute("Sum(["+Column
> A+"])",String.Empty));
> //calculate column b for each row
> e.Item.Cells[2].Text = int32.Parse(e.Item.Cells[2].Text) / total;
> }
>
>
> once you understand what you are working with, you can compress it down
into
> this verse
>
> if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> ListItemType.AlternatingItem)
> e.Item.Cells[2].Text = int32.Parse(e.Item.Cells[2].Text) /
> Int32.Parse( ds.Tables[0].Compute("Sum(["+Column A+"])",String.Empty));
>
> i'd recommend a catch block because int32.parse throws on empty fields or
u
> really should use double.tryparse ...
>
>



Relevant Pages