Hi,
i wana set default value of multiple text boxes to zero in c# winform application. i have 5 text boxes n i wana show the sum in the 6th one which is dynamically entered in those 5 textboxes. i just wana put condition dt if any of the 5 textbox is empty its value should be set to zero so it cn also participate in calculation otherwis eits giving an error cz i have made a method for ds to take 5 values :
in a separate class:
public int add(int a, int b, int c, int d, int e)
{
total = (a + b + c + d + e);
return total;
}
on btn event:
sm = new fee_endow();
sm1 = sm.add(Convert.ToInt32(sum1.Text), Convert.ToInt32(sum2.Text), Convert.ToInt32(sum3.Text), Convert.ToInt32(sum4.Text), Convert.ToInt32(sum5.Text));
totalbox.Text = sm1.ToString();
i also tried to put boxes in array :
int[] sum = {sum1box.text, sum2box.text, sum3box.text, sum4box.text, sum5box.text}
foreach(int b in sum)
{
if (b is TextBox)
{
if (b.Text == "")
{
b.Text = 0;
}
}
}
bt it doesnt work plz help me wd ds anyone as am new to c# programming.
Thnx