Labeling many buttons in code

I am just getting started in Xojo and used to do VB programming 10+ years ago. I have 32 BevelButton on a windows, BevelButton1-32 and based on a listbox choice I want to label those buttons in the code using a loop. I am not sure how to address or point to each button in the loop process. I have tried to get help from the language ref and looked through some examples but, it just has not clicked with me yet. Any advice is greatly appreciated. THX JMW

Here is what I have:

// Dim cueButton(31) as String
Dim boxChoice as String
Dim x As Integer

boxChoice = Listbox1.Text

If boxChoice = “ArKoas” then
// update button labels
ElseIf boxChoice = “Picturall” then
//update button labels
Do until x >31
dim y as Integer = 1
BevelButton(y).Caption = ("Cue " + str(y))
x = x+1
y = y+1
loop
Else //boxChoice = “Playback Pro”
//update button labels
End If

[quote=124005:@James M Wadkins]I am just getting started in Xojo and used to do VB programming 10+ years ago. I have 32 BevelButton on a windows, BevelButton1-32 and based on a listbox choice I want to label those buttons in the code using a loop. I am not sure how to address or point to each button in the loop process. I have tried to get help from the language ref and looked through some examples but, it just has not clicked with me yet. Any advice is greatly appreciated. THX JMW

Here is what I have:

// Dim cueButton(31) as String
Dim boxChoice as String
Dim x As Integer

boxChoice = Listbox1.Text

If boxChoice = “ArKoas” then
// update button labels
ElseIf boxChoice = “Picturall” then
//update button labels
Do until x >31
dim y as Integer = 1
BevelButton(y).Caption = ("Cue " + str(y))
x = x+1
y = y+1
loop
Else //boxChoice = “Playback Pro”
//update button labels
End If[/quote]

BevelButton() is a control set, the code seems operational. Have you tried it ?

I get an error message “Type mismatch error. Expected Ptr, but got BevelButton” with BevelButton highlighted.

You need to make BevelButton1 a control set.

  • In the ide, drag a BevelButton over your window. It will be named BevelButton1.
  • In the inspector, call it anything you want, but NOT ‘BevelButton’, as this word is reserved.
  • Click on the gear icon on top of the inspector
  • Click on Member Of and make it “New Control Set”

Now you can duplicate your button 31 times with Ctrl-D (or Cmd-D on Mac), and it can be addressed with an index, as you do in your program.

Here is what I did with 10 buttons :

for y as integer = 0 to 9 BevelButton1(y).Caption = "Cue "+ str(y) next