F
franzklammer
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!!!
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!!!