Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
double n1, n2, n3, n4, n5, n6;
           float res;
           // n1 = Convert.ToInt32(txttui.Text);
           n1 = Convert.ToDouble(textBox1.Text);
           n2 = Convert.ToDouble(textBox2.Text);
           n3 = Convert.ToDouble(textBox3.Text);
           n4 = Convert.ToDouble(textBox4.Text);
           n5 = Convert.ToDouble(textBox5.Text);
           n6 = Convert.ToDouble(textBox6.Text);
           //  n6 = Convert.ToInt32(txthostl.Text);
           res = n1 + n2 + n3 + n4 + n5 + n6;

           //txttotalfee.Text = Convert.ToString(res);
           textBox27.Text = Convert.ToString(res);
Posted
Comments
Thanks7872 28-Nov-14 1:32am    
Don't you understand that we can not read your mind? We don't know what you are working on. We can not see your screen. After reading above title, no one can identify what the problem is.
OriginalGriff 28-Nov-14 1:57am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
TheRealSteveJudge 28-Nov-14 4:52am    
I agree to the comments above.

Is is that you want to achieve that the user can enter only numbers?

I think you are trying to prevent users to input character values. If this is your question then I have found below source code on internet. You can user this.

C#
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
        (e.KeyChar != '.'))
    {
            e.Handled = true;
    }

    // only allow one decimal point
    if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
    {
        e.Handled = true;
    }
}



You can use the same method for all your textboxes.
 
Share this answer
 
Hi,

I would like to suggest reading the following article:

Simple Validation in WPF[^]

Best regards,
Stephan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900