passing arrays from Class Module

navb

New Member
Joined
Mar 5, 2011
Messages
31
Hi I have a userform in which there are four Frames. Each frame has couple of checkboxes. Now I want that whatever checkboxes user clicks should be displayed in message box. The following code doesn't work as it says arrays cannot be declared as public members in class.

'Class 2
Private frame_content() As String


'Module
Sub check_valid_combo(ufm As UserForm)


Dim frame_collection As New Collection
Dim frame_array As Frame
Dim num


For i = 1 To 4' no. of frames
Dim Inst As New Class2
frame_collection.Add Item:=Inst, Key:=CStr(i)

Set frame_array = ufm.Controls("Frame" & i)
For Each ctrl In frame_array.Controls
If TypeName(ctrl) = "CheckBox" Then
If ctrl.Value Then
num = num + 1
ReDim Preserve frame_content(1 To num)
Inst.frame_content(num) = ctrl.Name
End If
End If
Next ctrl

Set Inst = Nothing
num = 0
Next i




For Each MyObject In frame_collection
For i = LBound(MyObject.frame_content) To UBound(MyObject.frame_content)
MsgBox MyObject.frame_content(i)
Next i
Next MyObject


For i = 1 To frame_collection.Count ' Remove name from the collection.
frame_collection.Remove 1 ' Since collections are reindexed
' automatically, remove the first
Next

End Sub
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,203,625
Messages
6,056,384
Members
444,862
Latest member
more_resource23

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