I was just trying to create a control array but I can't do it. What can I do? There's another sintax or it's just there's no control arrays in VB.NET????

This should work I believe.

dim pictureboxarray as list(of picturebox)

See if this helps.

'// Prerequisites: 3 Buttons
        Dim myCoolControls() As Control = {Button1, Button2, Button3}
        For Each onlyCoolControl As Control In myCoolControls : onlyCoolControl.BackColor = Color.SteelBlue : Next
commented: I got you dude. +1

I like that codeorder I might use that some time.

Neither of these appear to work for what I want to do, which is dynamically change text within large groups of labels as my program runs.

What if I've got a list of 10 labels that contain names, and circumstances come up where I'd want to change the name in Label5, say..., or labels 1, 3, and 7 based on some decision in the program?

[rant]

F*cking Microsoft with their change for the sake of change. Removing control arrays? Really? That's what they call an improvement? They never fail to disappoint me.

[/rant]

Here, I hope this helps.

Public Class Form1
    Dim myLabels(10) As Label
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        myLabels(1) = Label1
        myLabels(2) = Label2
        myLabels(3) = Label3
        myLabels(4) = Label4
        myLabels(5) = Label5
        myLabels(6) = Label6
        myLabels(7) = Label7
        myLabels(8) = Label8
        myLabels(9) = Label9
        myLabels(10) = Label10
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        myLabels(3).Text = "Hello World"
    End Sub
End Class
'// Pre-requisites: 3 Labels
        Dim myCoolControls() As Control = {Label1, Label2, Label3}
        '// since Arrays are Index based, Index 0 being Label1, this will change Label2's text.
        myCoolControls(1).Text = "Look, it works!  I like Microsoft afterall."
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.