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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:50:06+00:00 2026-05-16T14:50:06+00:00

I am trying to figure out how to go about creating dynamic checkboxes on

  • 0

I am trying to figure out how to go about creating dynamic checkboxes on my form when I do not know exactly how many boxes I will need.

The problem is that I do not know how to DIM more than one object. This is my code for creating one checkbox

Dim checkBox As New CheckBox()

Form1.Controls.Add(checkBox)
checkBox.Location = New Point(10, 10)
checkBox.Text = "testing"
checkBox.Checked = True
checkBox.Size = New Size(100, 20)

It works just fine but i am unable to add more than one checkBox without having to do this:

Dim checkBox As New CheckBox()
Dim checkBox2 As New CheckBox()

Form1.Controls.Add(checkBox)
checkBox.Location = New Point(10, 10)
checkBox.Text = "testing"
checkBox.Checked = True
checkBox.Size = New Size(100, 20)

Form1.Controls.Add(checkBox2)
checkBox2.Location = New Point(40, 10)
checkBox2.Text = "testing2"
checkBox2.Checked = True
checkBox2.Size = New Size(100, 20)

etc…

Is there a way to dim more than 1 checkbox instead of having to write multiple dim statements for each checkBoxe?


Sorry maybe i should say this..

I’m looking to do something like this:

 dim checkBox() as CheckBox

 do until i = 50
    Form1.Controls.Add(checkBox(i))
    checkBox(i).Location = New Point(10, 10)
    checkBox(i).Text = "testing " & i
    checkBox(i).Checked = True
    checkBox(i).Size = New Size(100, 20)
    i += 1
 loop

  • 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-16T14:50:06+00:00Added an answer on May 16, 2026 at 2:50 pm

    It seems like the only items that are different and not calculated between the CheckBox instances is the text. If so then you could just use the following code to add a set of CheckBox instances based off of a list of String‘s.

    Dim data as String() = New String() { "testing", "testing2" }
    Dim offset = 10
    For Each cur in data 
      Dim checkBox = new CheckBox()
      Form1.Controls.Add(checkBox)
      checkBox.Location = New Point(offset, 10)
      checkBox.Text = cur
      checkBox.Checked = True
      checkBox.Size = New Size(100, 20)
      offset = offset + 30
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to go about writing a website monitoring script
I am learning about recursion tree's and trying to figure out how the height
my questions is about iPhone development. I'm trying to figure out if there is
Trying to figure out how to type (via events not set the value) on
Trying to figure out why my recipient multiselect isn't validating on form submission. Should
I'm trying to figure out a good design for a Spring/Hibernate app. When creating
I'm trying to figure out a way to write a query that will pull
I am currently trying to figure out how to best go about implementing an
I'm trying to figure out a way to store metadata about a column without
Trying to figure out how I can do this properly. The print_r looks like

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.