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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,537
Messages
6,120,096
Members
448,944
Latest member
SarahSomethingExcel100

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