create a control array

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi Im kind of new at this vb, trying hard to learn it. I have a form with frames. Nead to create a control array and have no idea of what I am doing.. Please help. Thx Dan
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Not sure exactly what you mean by control array or what you want. But try the following code:

Dim toppostition, counter As Integer
counter = 5

For I = 1 To counter
Set myoptionbuttons(I) = MyFrame.Controls.Add("Forms.optionbutton.1")
myoptionbuttons(I).Left = 0
myoptionbuttons(I).Top = topposition
myoptionbuttons(I).Width = 66
myoptionbuttons(I).Height = 18
myoptionbuttons(I).value= false
myoptionbuttons(I).caption = Range("A" & counter).Value
topposition = topposition + 18
Next I

This code will place 5 optionbuttons underneath each other starting at the top left corner of a frame called "MyFrame" and set the caption to the values in cells A1 through A5.


_________________
Hope this helps.
Kind regards, Al.
This message was edited by Al Chara on 2002-03-22 19:38
 
Upvote 0
My problem is under this frame all option boxes have the same name with different captions. And I keep getting the error message - ambigouos name.
 
Upvote 0
Each object must have it's own unique name

A control array with optionbuttons for ex. would look like the following

optionbutton(0).caption
optionbutton(1).caption
optionbutton(2).caption
optionbutton(3).caption

Unless VBA 6.0 has changed from 5.0, you cannot create a control array
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top