+ Reply to Thread
Results 1 to 4 of 4

array within array

  1. #1
    franzklammer
    Guest

    array within array

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

  2. #2
    Bob Phillips
    Guest

    Re: array within array

    Did you see my response in your previous thread?

    --
    HTH

    Bob Phillips

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

    "franzklammer" <franzklammer@discussions.microsoft.com> wrote in message
    news:07236E3C-D4C7-464D-A1B0-DFBF739FFCC8@microsoft.com...
    > 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!!!




  3. #3
    franzklammer
    Guest

    RE: array within array

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


  4. #4
    Bob Phillips
    Guest

    Re: array within array

    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)

    "franzklammer" <franzklammer@discussions.microsoft.com> wrote in message
    news:30553C85-7930-483B-A83F-884DFFA3F6FB@microsoft.com...
    > 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!!!




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1