Hi everyone, I got a windows application using C# with alot of textboxes with numeric values. To be exact 99 textboxes. What will be the easiest way to count all the values and add to a total textbox? My code is working but now and then I get an issue and can't pin point the place of mistake. Just asking if the is an easier and more relyable methord. Yes I am stil very new with windows forms C#. Thank you
Here is my code:
private void CountSASSscore() { ///first Column double dblQVName11 = Convert.ToDouble( txtQVA1c.Text); double dblQVName12 = Convert.ToDouble( txtQVA2c.Text); double dblQVName13 = Convert.ToDouble( txtQVA3c.Text); double dblQVName14 = Convert.ToDouble( txtQVA4c.Text); double dblQVName15 = Convert.ToDouble( txtQVA5c.Text); double dblQVName16 = Convert.ToDouble( txtQVA6c.Text); double dblQVName17 = Convert.ToDouble( txtQVA7c.Text); double dblQVName18 = Convert.ToDouble( txtQVA8c.Text); double dblQVName19 = Convert.ToDouble( txtQVA9c.Text); double dblQVName110 = Convert.ToDouble( txtQVA10c.Text); double dblQVName111 = Convert.ToDouble( txtQVA11c.Text); double dblQVName112 = Convert.ToDouble( txtQVA12c.Text); double dblQVName113 = Convert.ToDouble( txtQVA13c.Text); double dblQVName114 = Convert.ToDouble( txtQVA14c.Text); double dblQVName115 = Convert.ToDouble( txtQVA15c.Text); double dblQVName116 = Convert.ToDouble( txtQVA16c.Text); double dblQVName117 = Convert.ToDouble( txtQVA17c.Text); double dblQVName118 = Convert.ToDouble( txtQVA18c.Text); double dblQVName119 = Convert.ToDouble( txtQVA19c.Text); double dblQVName120 = Convert.ToDouble( txtQVA20c.Text); double dblQVName121 = Convert.ToDouble( txtQVA21c.Text); double dblQVName122 = Convert.ToDouble( txtQVA22c.Text); double dblQVName123 = Convert.ToDouble( txtQVA23c.Text); double dblQVName124 = Convert.ToDouble( txtQVA24c.Text); double dblQVName125 = Convert.ToDouble( txtQVA25c.Text); double dblQVName126 = Convert.ToDouble( txtQVA26c.Text); double dblQVName127 = Convert.ToDouble( txtQVA27c.Text); double dblQVName128 = Convert.ToDouble( txtQVA28c.Text); double dblQVName129 = Convert.ToDouble( txtQVA29c.Text); double dblQVName130 = Convert.ToDouble( txtQVA30c.Text); double dblQVName131 = Convert.ToDouble( txtQVA31c.Text); double dblQVName132 = Convert.ToDouble( txtQVA32c.Text); double dblQVName133 = Convert.ToDouble( txtQVA33c.Text); double dblQVName134 = Convert.ToDouble( txtQVA34c.Text); double dblQVName135 = Convert.ToDouble( txtQVA35c.Text); double dblQVName136 = Convert.ToDouble( txtQVA36c.Text);
///Second Column double dblQVName21 = Convert.ToDouble( txtQVB1c.Text); double dblQVName22 = Convert.ToDouble( txtQVB2c.Text); double dblQVName23 = Convert.ToDouble( txtQVB3c.Text); double dblQVName24 = Convert.ToDouble( txtQVB4c.Text); double dblQVName25 = Convert.ToDouble( txtQVB5c.Text); double dblQVName26 = Convert.ToDouble( txtQVB6c.Text); double dblQVName27 = Convert.ToDouble( txtQVB7c.Text); double dblQVName28 = Convert.ToDouble( txtQVB8c.Text); double dblQVName29 = Convert.ToDouble( txtQVB9c.Text); double dblQVName210 = Convert.ToDouble( txtQVB10c.Text); double dblQVName211 = Convert.ToDouble( txtQVB11c.Text); double dblQVName212 = Convert.ToDouble( txtQVB12c.Text); double dblQVName213 = Convert.ToDouble( txtQVB13c.Text); double dblQVName214 = Convert.ToDouble( txtQVB14c.Text); double dblQVName215 = Convert.ToDouble( txtQVB15c.Text); double dblQVName216 = Convert.ToDouble( txtQVB16c.Text); double dblQVName217 = Convert.ToDouble( txtQVB17c.Text); double dblQVName218 = Convert.ToDouble( txtQVB18c.Text); double dblQVName219 = Convert.ToDouble( txtQVB19c.Text); double dblQVName220 = Convert.ToDouble( txtQVB20c.Text); double dblQVName221 = Convert.ToDouble( txtQVB21c.Text); double dblQVName222 = Convert.ToDouble( txtQVB22c.Text); double dblQVName223 = Convert.ToDouble( txtQVB23c.Text); double dblQVName224 = Convert.ToDouble( txtQVB24c.Text); double dblQVName225 = Convert.ToDouble( txtQVB25c.Text); double dblQVName226 = Convert.ToDouble( txtQVB26c.Text); double dblQVName227 = Convert.ToDouble( txtQVB27c.Text); double dblQVName228 = Convert.ToDouble( txtQVB28c.Text); double dblQVName229 = Convert.ToDouble( txtQVB29c.Text); double dblQVName230 = Convert.ToDouble( txtQVB30c.Text); double dblQVName231 = Convert.ToDouble( txtQVB31c.Text); double dblQVName232 = Convert.ToDouble( txtQVB32c.Text); double dblQVName233 = Convert.ToDouble( txtQVB33c.Text); double dblQVName234 = Convert.ToDouble( txtQVB34c.Text); double dblQVName235 = Convert.ToDouble( txtQVB35c.Text); double dblQVName236 = Convert.ToDouble( txtQVB36c.Text); double dblQVName237 = Convert.ToDouble( txtQVB37c.Text); double dblQVName238 = Convert.ToDouble( txtQVB38c.Text);
///Third Column double dblQVName31 = Convert.ToDouble( txtQVC1c.Text); double dblQVName32 = Convert.ToDouble( txtQVC2c.Text); double dblQVName33 = Convert.ToDouble( txtQVC3c.Text); double dblQVName34 = Convert.ToDouble( txtQVC4c.Text); double dblQVName35 = Convert.ToDouble( txtQVC5c.Text); double dblQVName36 = Convert.ToDouble( txtQVC6c.Text); double dblQVName37 = Convert.ToDouble( txtQVC7c.Text); double dblQVName38 = Convert.ToDouble( txtQVC8c.Text); double dblQVName39 = Convert.ToDouble( txtQVC9c.Text); double dblQVName310 = Convert.ToDouble( txtQVC10c.Text); double dblQVName311 = Convert.ToDouble( txtQVC11c.Text); double dblQVName312 = Convert.ToDouble( txtQVC12c.Text); double dblQVName313 = Convert.ToDouble( txtQVC13c.Text); double dblQVName314 = Convert.ToDouble( txtQVC14c.Text); double dblQVName315 = Convert.ToDouble( txtQVC15c.Text); double dblQVName316 = Convert.ToDouble( txtQVC16c.Text); double dblQVName317 = Convert.ToDouble( txtQVC17c.Text); double dblQVName318 = Convert.ToDouble( txtQVC18c.Text); double dblQVName319 = Convert.ToDouble( txtQVC19c.Text); double dblQVName320 = Convert.ToDouble( txtQVC20c.Text); double dblQVName321 = Convert.ToDouble( txtQVC21c.Text); double dblQVName322 = Convert.ToDouble( txtQVC22c.Text); double dblQVName323 = Convert.ToDouble( txtQVC23c.Text); double dblQVName324 = Convert.ToDouble( txtQVC24c.Text); double dblQVName325 = Convert.ToDouble( txtQVC25c.Text);
double dblTotal;
dblTotal = dblQVName11 + dblQVName12 + dblQVName13 + dblQVName14 + dblQVName15 + dblQVName16 + dblQVName17 + dblQVName18 + dblQVName19 + dblQVName110 + dblQVName111 + dblQVName112 + dblQVName113 + dblQVName114 + dblQVName115 + dblQVName116 + dblQVName117 + dblQVName118 + dblQVName119 + dblQVName120 + dblQVName121 + dblQVName122 + dblQVName123 + dblQVName124 + dblQVName125 + dblQVName126 + dblQVName127 + dblQVName128 + dblQVName129 + dblQVName130 + dblQVName131 + dblQVName132 + dblQVName133 + dblQVName134 + dblQVName135 + dblQVName136 + dblQVName21 + dblQVName22 + dblQVName23 + dblQVName24 + dblQVName25 + dblQVName26 + dblQVName27 + dblQVName28 + dblQVName29 + dblQVName210 + dblQVName211 + dblQVName212 + dblQVName213 + dblQVName214 + dblQVName215 + dblQVName216 + dblQVName217 + dblQVName218 + dblQVName219 + dblQVName220 + dblQVName221 + dblQVName222 + dblQVName223 + dblQVName224 + dblQVName225 + dblQVName226 + dblQVName227 + dblQVName228 + dblQVName229 + dblQVName230 + dblQVName231 + dblQVName232 + dblQVName233 + dblQVName234 + dblQVName235 + dblQVName236 + dblQVName237 + dblQVName238 + dblQVName31 + dblQVName32 + dblQVName33 + dblQVName34 + dblQVName35 + dblQVName36 + dblQVName37 + dblQVName38 + dblQVName39 + dblQVName310 + dblQVName311 + dblQVName312 + dblQVName313 + dblQVName314 + dblQVName315 + dblQVName316 + dblQVName317 + dblQVName318 + dblQVName319 + dblQVName320 + dblQVName321 + dblQVName322 + dblQVName323 + dblQVName324 + dblQVName325;
txtSASSSCore.Text = dblTotal.ToString(); }