You could use this code to reduce the amount of code you type, It could make
it more readable. This code will check for all controls in the screen and if
that control is a textbox, it will add that data into a variable.
You could use a if condition if u do not want to add few textbox data. You
wouldnt want to add textbox like name, id and stuff like that... just use
one more condition like if((ctrl.Name != txtName) && (ctrl.Name != txtId))
and so on.
Type t = typeof(System.Windows.Forms.TextBox);
decimal numTxtCount = 0;
foreach(Control ctrl in this.Controls)
{
if (ctrl.GetType() == t)
{
numTxtCount += Decimal.Parse(ctrl.Text);
}
}
--
Tarkeshwar L
..Net Programmer
Fifth Generation Technologies
"RobRich" <ro*@fastbreakpizza.com> wrote in message
news:BfFhd.345344$3l3.263594@attbi_s03...
I'm trying to figure out the best way to accomplish a task. I need to
calculate the numerical values from
about 300+ textboxes. Basiclly I have an application that users input
checks and credit card receipts into
and the program calculates the total.. Right now I am just doing
Decimal.Parse(textbox1.Text) + Decimal.Parse(textbox2.Text) + etc...
So is this what I should be doing to accomplish what I'm trying to do?
The application works fine using
that functionality but not sure if thats the best way to code the
application..
Any suggestions welcome.
Thanks