Multiple Button

omoba

Active Member
Licensed User
Longtime User
I want to to change a property of 20 buttons.

How do I do this without setting each button line by line

Eg. Can I avoid as shown below?

Button1.Typeface = MyFont
.
.
.
.
Button20.Typeface = MyFont
 

enonod

Well-Known Member
Licensed User
Longtime User
Put the buttons in an array/list and iterate the array/list. In this case each button should not have a unique name but be referred to always by its array/list position.
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
I have tried but I am doing something and cant figure what wrong. I am get an error message

Object should first be inititalized (Button)

Sub Setup

Dim Button(20) as Button

For i = 1 To 20
Button(i).Typeface = MyFont
Next

End Sub
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
inside the for loop put button(i).initialize
[Edit] before you refer to the button
 
Last edited:
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
I may be wrong but I think you will have to remove them from designer and within the loop you have, add for each button, the coordinates you require them on the panel or whatever view they are to be on. In some ways you have more control if you declare the items in code especially if their relative positions follow a mathematical algorithm.
i.e. Button(i).left=200dip or Button(i).left=i*56dip. etc. etc.
 
Upvote 0
Top