PDA

View Full Version : passing arrays from Class Module



navb
01-17-2014, 03:58 PM
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

snb
01-17-2014, 06:20 PM
Please use code tags !!

You might have a look over here:

VBA for smarties: VBA check of userinput in a Userform (http://www.snb-vba.eu/VBA_Userform_invoercontrole_en.html)