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

  • Home
  • SEARCH
  • 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 8449203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:38:23+00:00 2026-06-10T10:38:23+00:00

I am trying to take the values in the textboxes, named sequentially from 0-9,

  • 0

I am trying to take the values in the textboxes, named sequentially from 0-9, and add that to a List using a for loop. I am having problems with the syntax or something.

here is what I have now.

for (int i = 0; i <= amt.Count(); i++)
        {
            amt[i] = int.Parse(amtBox[i].Text);
        }

The error is that amtBox doesnt exist in the current context.

My problem is within the loop where i have amtBox[i].Text. I have tried this several ways and VS always throws an error. I have tried “amtBox” + i and that compiles but then causes an error when I try to do something with it and says “data is of wrong type”.

I am new to C# and come from PHP so maybe that is why I think this approach will work. PHP doesnt care about data types where C# really does. I have done this exact thing in PHP many times without any issue.

Any suggestions on another way to do this are appreciated as I am probably coming at this all wrong.

Thanks

  • 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-06-10T10:38:25+00:00Added an answer on June 10, 2026 at 10:38 am

    One solution would be to declare an array and assign amtBox’es to the individual indexes in the array and then you can iterate on that array.

    var amtBoxes = new TextBox[] { amtBox0, amtBox1, .... };
    for (int i = 0; i <= amt.Count(); i++)
    {
        amt[i] = int.Parse(amtBoxes[i].Text);
    }
    

    If you end up needing to iterate on your TextBox controls in other places I would consider making the array an instance member of your object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a piece of software that will take values from an
I am trying to take in array which contains some integer values/string values from
What i want to do is take particular values from a list of strings
I'm trying to take values from a from and then and when it is
I'm trying to take values from this string: -webkit-gradient(linear, right top, left top, color-stop(0,
I am trying to take the values from the text fields below to use
I am trying to loop through an array to take certain values and set
I am trying to take data from an array using Facebook Open Graph. I
I'm trying to figure out how to take values from one of these input
I'm trying to take values from a table and put them into a string

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.