|
-
Nov 1st, 2007, 02:45 PM
#1
Thread Starter
Member
[RESOLVED] Help referencing a control as a string to get around no control arrays
Hello,
I am trying to get around the lack of control arrays. I have 4 list boxes that I am trying to reference and add items to. VB6 had a cool controls function like the following.
Controls("List" & 1).AddItem ("Test")
I can't for the life of me figure this out in VB 2005.
Any help would greatly be appreciated.
Last edited by Mythos44; Nov 1st, 2007 at 03:38 PM.
Reason: [RESOLVED]
-
Nov 1st, 2007, 03:00 PM
#2
Re: Help referencing a control as a string to get around no control arrays
Control arrays exist in .Net, you just dont create them in the same way as in VB6. Try a search.
-
Nov 1st, 2007, 03:02 PM
#3
Hyperactive Member
Re: Help referencing a control as a string to get around no control arrays
Control arrays are just set a different way.
Code:
Private LB() As ListBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LB = New ListBox() {Me.ListBox1, Me.ListBox2, Me.ListBox3, Me.ListBox4}
End Sub
For i As Integer = 0 To LB.Length - 1
LB(i).Items.Add(i.ToString)
Next
-
Nov 1st, 2007, 03:39 PM
#4
Thread Starter
Member
Re: [RESOLVED] Help referencing a control as a string to get around no control arrays
Thank you so much that worked Awesome. It is greatly appreciated.
Mythos
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|