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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:59:19+00:00 2026-05-27T21:59:19+00:00

Love these forums, I am a beginner when it comes to VB.NET and have

  • 0

Love these forums, I am a beginner when it comes to VB.NET and have run into some trouble.

Here is my Code snippet

    'decleare variables
    Dim vmcount As Integer
    Dim tabcount As Integer
    Dim userControl As Control
    Dim UserControlName As String

    vmcount = combo_vmcount.SelectedItem

    tabcount = 1

    tab_con_vm.TabPages.Clear()


    While (tabcount <= vmcount)

        Dim tabname As New TabPage

        'Load variables
        userControl = New calc_usercontrol_vm

        tabname.Text = "VM" & tabcount

        tabname.Name = "VM" & tabcount

        UserControlName = "UCVM" & tabcount

        userControl.Name = UserControlName

        'actions
        tab_con_vm.TabPages.Add(tabname)


        tabname.Controls.Add(userControl)

         'next
        tabcount = tabcount + 1


    End While
End Sub

The trouble I’m having is working out a way to be able to call the objects in the dynamically created usercontrols. I thought a list maybe an option but I am struggling to get the syntax/get it working. Wondering if anyone has some ideas or different approaches..

Thanks Guys
Richard

  • 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-27T21:59:20+00:00Added an answer on May 27, 2026 at 9:59 pm

    While this is most likely not the best way to solve the problem, I ended up creating an global array and build the user controls off that.

    ' USERCONTROL ARRAY
    Public UCVMARRAY(30) As calc_usercontrol_vm
    
    
    
    
    
    
    Dim tabcount As Integer
    
        Dim UCVMARRAYindex As Integer
    
        Dim userControl As Control 'control variable
    
        Dim UserControlName As String
    
    
        vmcount = combo_vmcount.SelectedItem
    
        tabcount = 1
    
        UCVMARRAYindex = 0
    
        tab_con_vm.TabPages.Clear()
    
    
        While (tabcount <= vmcount)
    
            Dim tabname As New TabPage ' Relook at this to improve the method used. Issue was that new page was not generated on loop.
    
            'Load variables
    
            userControl = New calc_usercontrol_vm
            ' loads UC
    
            tabname.Text = "VM" & tabcount
    
            tabname.Name = "VM" & tabcount
    
            UserControlName = "UCVM" & tabcount
    
            userControl.Name = UserControlName
    
            UCVMARRAY(UCVMARRAYindex) = userControl 'places it back 
    
            'actions
            tab_con_vm.TabPages.Add(tabname)
    
            tabname.Controls.Add(userControl)
    
    
            'next
            tabcount = tabcount + 1
            UCVMARRAYindex = UCVMARRAYindex + 1
    
    
        End While
    End Sub
    

    It’s very basic but I got it working, the answers above are most likely a good solution but I my knowledge of vb.net were not up to scratch.

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

Sidebar

Related Questions

Is there a Maven alternative or port for the .NET world? I would love
I love the ease that the ASP.NET Ajax control Toolkit provides to ASP.NET developers.
I created and love my Asp.Net MVC2 application. It's a very nice DDD app
This is a general question, but I'd love some feedback. I'm new to working
Working with Extjs, GeoExt and OpenLayers, I more and more tend to run into
I love jQuery but am running into a problem with larger site and multiple
I have recently started studying Google Web Toolkit. I have went through some walkthroughs,
I have been playing around with webkit.net in a c# win forms project, and
I've just recently fallen in love with the world of ASP.NET MVC, and one
The more I use ASP.NET MVC, the more I love it. However, in the

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.