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 9012377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:58:51+00:00 2026-06-16T02:58:51+00:00

In my program there are multiple players who’s stats can all be increased at

  • 0

In my program there are multiple players who’s stats can all be increased at the same time.

Player 1 is represented by staminaTextBox[0] skillTextBox[0] LuckTexBox[0]

Player 2 is represented by staminaTextBox[1] skillTextBox[1] LuckTexBox[1]

etc.

I need my IncreaseStat method to deal with 3 different type of Textbox Overload e.g. Stamina, Skill, Luck

private void StaminaIncBtn_Click(object sender, EventArgs e)
{
    IncreaseStat(staminaText[0]);
}

private void LuckIncBtn_Click(object sender, EventArgs e)
{
    IncreaseStat(luckText[0]);
}

private void IncreaseStat(TextBox statText)
{
    for (int i = 0; i < 5 ; i++)
    {
        statText[i].Text = "Altered";
    }
}

This method is used to increase all 5 players stats at the same time.

It works fine if they are not control arrays, however I need them to be. I get the error
"Cannot apply indexing with [] to an expression of type 'System.Windows.Forms.TextBox". It applies to that fact that inside the method I am saying statText[i].

I do not understand how to get around this problem. Any suggestions would be more than welcome.

Thank you for your time.

  • 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-16T02:58:52+00:00Added an answer on June 16, 2026 at 2:58 am

    Would this be sufficient (with possible changes by yourself for your need)?

    private void IncreaseStat() {
        foreach (TextBox textBox in this.Controls.OfType<TextBox>().Where(x => x.Name.Contains("stamina") || 
                x.Name.Contains("skill") || 
                x.Name.Contains("Luck"))) {
            textBox.Text = "Altered";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a program which I can run like this: py2py.py < orig.py >
Is there a program to compare one folder and all subfolders to another folder
Is there any program code that can help me to pop up the virtual
My program simulates a video store. In my list there are multiple copies of
I'm currently working on a program where there are multiple icons dynamically added to
I'm writing a program to monitor a python script running. There will be multiple
The problem described below relates to an inventory tracking Java program. There are multiple
I have a program wherein there are multiple tabs added dynamically to a TabControl
I am writing a program where there is an object shared by multiple threads:
Lets say there are multiple functions throughout my program that need to append data

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.