array within array

G

Guest

Hello. I have a small problem that would be great to solve. I have a userform
in which I have textboxes and checkboxes. The textboxes are divided into two
different kinds based on the data that is to be submitted by the user and
then used by the program. In order to separate these two types of text boxes
I have placed them in two sepraret frames. Now I performe an operation that
is similare for the checkbox fields as well as the text box fields. The
operation counts the number of controls for a certain type of field
(checkboxes in the code below), sets the dimension of an array so that it
corresponds to the number of controls that are counted. It then populates the
array with the values from these fields. Now the operation is basically the
same for the two types of textboxes and the checkboxes. I therefore wonder if
it is possible to place the names of these three types of controls in an
array and then perform the operation by looping? This would be very nice but
I do not quite know how to write it. The code for these three operations are
submitted below.

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

Private Sub startDatumTextBoxSub()
Dim i As Long
Dim ctl As Control
Dim strStartDatumArray()
ReDim strStartDatumArray(0 To 0)
For Each ctl In Me.StartDatumRam.Controls
If TypeName(ctl) = "TextBox" Then
ReDim Preserve strStartDatumArray(0 To i)
strStartDatumArray(i) = ctl.Value
i = i + 1
End If
Next ctl
End Sub

Private Sub slutDatumTextBoxSub()
Dim i As Long
Dim ctl As Control
Dim strSlutDatumArray()
ReDim strSlutDatumArray(0 To 0)
For Each ctl In Me.SlutDatumRam.Controls
If TypeName(ctl) = "TextBox" Then
ReDim Preserve strSlutDatumArray(0 To i)
strSlutDatumArray(i) = ctl.Value
i = i + 1
End If
Next ctl
End Sub

As you can see they are wuite similar so looping should not be a problem but
I dont know how refer correctly. Please help me if you can!!!
 
B

Bob Phillips

Did you see my response in your previous thread?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
G

Guest

yes i saw it . Thank you vey much! However I intend to leave the program to
other people that perhaps want to add extra text fields etc. in the easiest
way possible. therefore any Tags would not work. Is there any other way or
perhaps the tag solution is the most appropiate for this task? Thank you very
much for your assistance Mr Philips!

"franzklammer" skrev:
 
B

Bob Phillips

Add a comment to the program and they should be able tom carry on in the
same way.
--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top