newbie question, working with array

J

Jurgen Oerlemans

Hello,

Being fairly new to vb (dotnet) programming, I have the following question:

I have 10 buttons from which I want to change background color, text
etcetera. Instead of making 10 lines of programming code I want to do this
by using an array. So what I tried is:
Dim btnArray As String() = {"btnfirst", "btnsecond", "btnthird", etcetera}

Dim S As String

For Each S In btnArray

S.BackColor = System.Drawing.Color.OrangeRed

Next



This doesn't work. Can anybody put me on the right track? Shouldn't be so
hard I think. Any help appreciated.

Regards, Jurgen
 
N

Nick Hounsome

Jurgen Oerlemans said:
Hello,

Being fairly new to vb (dotnet) programming, I have the following
question:

I have 10 buttons from which I want to change background color, text
etcetera. Instead of making 10 lines of programming code I want to do this
by using an array. So what I tried is:
Dim btnArray As String() = {"btnfirst", "btnsecond", "btnthird",
etcetera}

Dim S As String

For Each S In btnArray

S.BackColor = System.Drawing.Color.OrangeRed

Next



This doesn't work. Can anybody put me on the right track? Shouldn't be so
hard I think. Any help appreciated.

Regards, Jurgen

Buttons are buttons and strings are strings duh!

....
Dim btnArray as Button() = { btnfirst, btnsecond };
....
Dim S as Button
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,405
Messages
2,571,535
Members
48,796
Latest member
shadowoftheunknown

Latest Threads

Top