I am finally getting around to upgrading an old program from VB6 to VB2015 and I have run into my first hurdle. It appears that VB2015 doesn't do control arrays. In VB6 if you wanted a collection of 15 checkboxes you could copy and paste at design time and end up with a checkbox control array named check_myname(0), check_myname(1), check_myname(2), etc and it was very easy to make changes to the property values.
As far as I can tell VB2015 can't do this! This is so frustrating.
I used this VB2015 code at runtime to create 15 checkboxes on tabpage4 of my tabcontrol1:
It all works great. The only problem is that now when it comes time to changing the properties of the dynamically created checkboxes. There doesn't seem to be an easy elegant solution like in VB6.Code:Dim offset = 45 For tmp = 0 To 14 Dim checkBox_myname = New CheckBox() TabPage4.Controls.Add(checkBox_myname) checkBox_myname.Location = New Point(390, offset) checkBox_myname.Size = New Size(300, 17) checkBox_myname.BackColor = Color.FromArgb(82, 92, 106) checkBox_myname.ForeColor = Color.Silver checkBox_myname.FlatStyle = FlatStyle.Standard checkBox_myname.Font = New System.Drawing.Font("Tahoma", 8, FontStyle.Bold) checkBox_myname.TextAlign = ContentAlignment.MiddleLeft checkBox_myname.BringToFront() offset = offset + 21 Next tmp
For instance in VB6 if I wanted to change the visible property of a specific checkbox it would be something like this:
Very simple and elegant. How on earth would you do this in VB2015? All the solutions I have seen are insanely complicated. Am I missing an easy solution?Code:check_myname(5).Visible = false
Thanks.




Reply With Quote
