Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:21:52+00:00 2026-05-30T06:21:52+00:00

I have 8 textboxes that only accept integers. How to calculate the total of

  • 0

I have 8 textboxes that only accept integers. How to calculate the total of value entered by users in each textbox and the result will be showed as a label. After user click on submit button, the the value of the label(result of numbers) will be stored in db. Anyone knows? Thank you. Looking forward to hear from u guys.
I got this error : Input string was not in a correct format.
At this line:

int total = 0;
total = int.Parse(TextBox2.Text) + int.Parse(TextBox4.Text) + int.Parse(TextBox6.Text) + int.Parse(TextBox8.Text) + int.Parse(TextBox10.Text) + int.Parse(TextBox12.Text) + int.Parse(TextBox14.Text) + int.Parse(TextBox16.Text);    
Label1.Text = total.ToString(); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:21:53+00:00Added an answer on May 30, 2026 at 6:21 am

    You can do this way:-

    totalValue = int.Parse(txtBox1.Text) + int.Parse(txtBox2.Text) + int.Parse(txtBox3.Text) + int.Parse(txtBox4.Text) + int.Parse(txtBox5.Text) + int.Parse(txtBox6.Text) + int.Parse(txtBox7.Text) + int.Parse(txtBox8.Text);
    

    Store the value in label

    label.Text = totalValue;
    

    OR

    foreach (Control c in this.Controls)
    {
    if (c.GetType().Name.ToString()==”TextBox”)
    {
    totalValue += int.Parse(String.Format(“txtBox{0}.Text”, count));
    }
    }

    foreach (Control c in this.Controls)
    {               
            if (c.GetType().Name.ToString()=="TextBox")
           {
                    int value = 0;
                    if(int.TryParse(((TextBox)c).Text,out value))
                         totalValue += value;
           }
    }
    

    Store the value in label

    label.Text = totalValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET web page that contains many textboxes. Each textbox has a
I want to validate textbox so that it will accept only future date. Can
I have a textbox that should accept datetime formats only. I am not sure
I have a textbox that accepts only these values: . , - $ m
I have a textbox that I would like for only numbers. But if I
I have a number of textboxes that will be displayed with their existing values.
I have a TextBox which I'm using to handle numbers. I therefore only accept
I have many textboxes that need to be enabled only when certain action are
I have 25 textboxes. I have one button that will paste information in a
i have 2 textboxes that i am filling with StartDate, and Endate. i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.