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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:22:24+00:00 2026-06-06T05:22:24+00:00

I am creating a chess program. And it is composed of sixty four picture

  • 0

I am creating a chess program. And it is composed of sixty four picture boxes with alternating black and white background colours.
I have named them pba1, pba2, pbb1, pbb2, pbc1 and so on.
Now, I want to loop through only the black ones, for example, I want to loop through only, pba1, pbb2, pbc3 and so on.
How do I create a loop for this in VB.NET?

I know of the way to loop through similarly named controls, but I am not able to adapt that method for my problem. Can you tell me a solution?

EDIT: In pba1, pb stands for picture box, and a1 stands for the square. Just in case, you wonder why such a name.

EDIT: Check out this answer

  • 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-06T05:22:26+00:00Added an answer on June 6, 2026 at 5:22 am

    Generating controls at design time via the Forms Designer only makes sense for layouts which benefit from the forms designer.

    In your case, you just have 64 uniform boxes in 8 rows of 8. Don’t use the Forms Designer for this, create the controls at runtime, and don’t give them names like pba1, just put them into an appropriate data structure (such as an 8×8 array):

    Private chessFields As PictureBox(8, 8)
    
    ' In Form_Load:
    For i = 0 To 7
        For j = 0 To 7
            chessFields(i, j) = New PictureBox
            ' Set size, position … then, finally,
            Controls.Add(chessFields(i, j))
        Next
    Next
    

    That way, you can access the fields in an orderly fashion without having to go via the Form.Controls collection.

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

Sidebar

Related Questions

I'm creating a variant of a chess-like program that needs to simultaneously generate and
Hi I have been learning Java Swing for creating a chess game to practice
I'm making a chess program and currently have the movement done for the pawn
I am creating a multiplayer chess game in Visual Basic.Net and I need to
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Creating an installer for possible remote systems so that if they do not have
Creating a C# install package and I'd like on completed install for the Program
Creating a login page in xcode 4.2 I have the users fill out information
I am creating simple chess board game in java, and they are running smoothly,
Hello I am in the process of creating a chess board where you can

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.