RE: array within array
- From: franzklammer <franzklammer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 21 Jun 2006 06:20:02 -0700
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:
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!!!
- Follow-Ups:
- Re: array within array
- From: Bob Phillips
- Re: array within array
- Prev by Date: Re: macro which works in excel 2000 does not work in excel 2002
- Next by Date: Re: Macro launches VB IDE window
- Previous by thread: Re: array within array
- Next by thread: Re: array within array
- Index(es):