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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:55:52+00:00 2026-05-23T15:55:52+00:00

I have the following code: For Each control2 As Control In GroupBox3.Controls If TypeOf

  • 0

I have the following code:

    For Each control2 As Control In GroupBox3.Controls
        If TypeOf control2 Is TextBox Then
            Dim txt2 As TextBox = TryCast(control2, TextBox)
            If counter > totalBoxes Then
                totalBoxes += 1
                txt2.Text = grade(totalBoxes)
            End If
        End If
    Next

What I am doing is looping through each textbox in groupbox3. Then checking if the counter(total number of grades that are inputted in the form) are greater than the totalBoxes(which is set to 0) and finally I am putting the actual grade(A,B,C,D) into the textbox. The problem is that it is starting the loop at textbox 8(I have 10 textboxes) for some reason and going from there. Does anyone know what the problem is with my code?

Aaron

  • 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-23T15:55:53+00:00Added an answer on May 23, 2026 at 3:55 pm

    Well, the name of your textbox has no relation to its index in the .Controls collection of its parent.

    One thing you could do is set the .tag property of each of your controls to the index you’d like to pass into your grade function.

    textbox1.Tag = 1
    textbox2.Tag = 2
    ...
    

    That way you don’t have to worry about which order the textboxes are in while iterating.

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

Sidebar

Related Questions

I have the following code for a slider control in WPF: occuranceTimeSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
If I have the following code : threads = [] (1..5).each do |i| threads
I have the following code: Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(,) (Essentially I'm trying to build a
I have several blocks of the following code that each use there own matrix.
I have the following code which I use to match fancybox possible elements: $('a.grouped_elements').each(function(){
I have the following SQL code that runs against a Change Request database. Each
The following code returns the error from the For Each loop. I have similar
I have the following code in an Asp.Net user control: Me.pnlAddComment.Visible = MyBase.Associate.IsAgent() Me.lblRating.Visible
I have the following code, repeated on each Form , as part of the
i have default.aspx page and one user control. usercontrol is having following code for

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.