F
Fabrizio
I set the dimensions of an array in a loop in in a sub that belongs to a user
form. this works fine. however when i try to access the array or its
dimension in another sub it does not work. the program says "index oustide of
interval". now the array is declared public in a modul (not the userform). i
want to be ablle to use the array, its dimension and contents both in the
user form and in the modul. how shall i code it? My code in the userform is:
Private Sub pressButton_Click()
Call checkBoxSub
Call mainProgram
Unload Me
End Sub
Private Sub checkBoxSub()
Dim i As Long
Dim ctl As Control
Dim blnCheckBoxArray()
ReDim blnCheckBoxArray(0 To 0)
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
ReDim Preserve blnCheckBoxArray(0 To i)
blnCheckBoxArray(i) = ctl.Value
i = i + 1
End If
Next ctl
End Sub
as you can see the upper sub calls the lower sub but the upper sub cannot
access the array. as i said it is declared public....Please help me! I dont
understand!!
form. this works fine. however when i try to access the array or its
dimension in another sub it does not work. the program says "index oustide of
interval". now the array is declared public in a modul (not the userform). i
want to be ablle to use the array, its dimension and contents both in the
user form and in the modul. how shall i code it? My code in the userform is:
Private Sub pressButton_Click()
Call checkBoxSub
Call mainProgram
Unload Me
End Sub
Private Sub checkBoxSub()
Dim i As Long
Dim ctl As Control
Dim blnCheckBoxArray()
ReDim blnCheckBoxArray(0 To 0)
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then
ReDim Preserve blnCheckBoxArray(0 To i)
blnCheckBoxArray(i) = ctl.Value
i = i + 1
End If
Next ctl
End Sub
as you can see the upper sub calls the lower sub but the upper sub cannot
access the array. as i said it is declared public....Please help me! I dont
understand!!