Textbox control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DonnaDarko
    New Member
    • Mar 2007
    • 8

    #1

    Textbox control

    I hope someone can help me!! I am fairly new at VB and I have already tried searching for the answer...hope this isn't a repeat.

    Question is: I want to disable/enable an array of textboxes, e.g. Text2(i).Text, located in frmexposurepath s within the frame called receptor. What i have so far:

    If blah blah Then
    frmexposurepath s!Text2(i).Text .Enabled = False
    Else
    frmexposurepath s!Text2(i).Text .Enabled = True
    End If

    But obviously this doesn't work. :) Any ideas?

    DonnaDarko
  • Taftheman
    New Member
    • Nov 2006
    • 93

    #2
    Originally posted by DonnaDarko
    I hope someone can help me!! I am fairly new at VB and I have already tried searching for the answer...hope this isn't a repeat.

    Question is: I want to disable/enable an array of textboxes, e.g. Text2(i).Text, located in frmexposurepath s within the frame called receptor. What i have so far:

    If blah blah Then
    frmexposurepath s!Text2(i).Text .Enabled = False
    Else
    frmexposurepath s!Text2(i).Text .Enabled = True
    End If

    But obviously this doesn't work. :) Any ideas?

    DonnaDarko
    Hi if you are already in that form then just get rid of the frmexposurepath s
    <code>
    if blah blah then
    text2(i).enable = false
    Else
    text2(i).enable = true
    end if
    </code>

    if however you need to relate it with another form, then

    <code>
    if blah blah then
    frmexposurepath s.text2(i).enab le = false
    Else
    frmexposurepath s.text2(i).enab le = true
    end if
    </code>

    Comment

    • DonnaDarko
      New Member
      • Mar 2007
      • 8

      #3
      With the changes you suggested, it now picks and chooses elements from 'i' and doesn't disable/enable the entire array?!!

      Please advise again and thanks in advance!

      If receptor.Option 1(1).Value = True Then
      Check1(1).Enabl ed = False
      Check1(1).Value = 0
      frmexposurepath s.Text2(i).Enab led = False
      Else
      Check1(1).Enabl ed = True
      Check1(1).Value = 1
      frmexposurepath s.Text2(i).Enab led = True
      End if

      Comment

      • Geoff
        New Member
        • Feb 2007
        • 17

        #4
        For it to work over the entire array there is many ways you could do it.

        One of the preferd ways would be doing a loop.

        Code:
        Dim intA as Integer
        For intA = 1 to 10
           If receptor.Option1(intA).Value = True Then
              Check1(intA).Enabled = False
              Check1(intA).Value = 0
              frmexposurepaths.Text2(intA).Enabled = False
           Else
              Check1(intA).Enabled = True
              Check1(intA).Value = 1
              frmexposurepaths.Text2(intA).Enabled = True
           End if
        Next intA
        With this you'd have to change the line:
        Code:
        For intA = 1 to 10
        to the place in the array you'd like to modify... at the moment this would go from array item 1 - 10.

        Hope it helps,
        Geoff.

        Comment

        • DonnaDarko
          New Member
          • Mar 2007
          • 8

          #5
          Hello again!

          What was suggested so far, isn't working. It gets lost in the array somewhere, confusing i think the number of elements associated with the Option1(i) button, which goes from 0 to 2, and the Check1(i) array, which goes from 0 to 14.


          Here is what I now have, which doesn't work at all:

          Dim intA As Integer
          For intA = 1 To 14
          If receptor.Option 1(intA).Value = True Then
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text2(intA).E nabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text4(intA).E nabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text5(intA).E nabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text6(intA).E nabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text7(intA).E nabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text11(intA). Enabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text12(intA). Enabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text13(intA). Enabled = False
          Check1(intA).En abled = False
          Check1(intA).Va lue = 0
          frmexposurepath s.Text14(intA). Enabled = False
          Else
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text2(intA).E nabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text4(intA).E nabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text5(intA).E nabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text6(intA).E nabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text7(intA).E nabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text11(intA). Enabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text12(intA). Enabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text13(intA). Enabled = True
          Check1(intA).En abled = True
          Check1(intA).Va lue = 1
          frmexposurepath s.Text14(intA). Enabled = True
          End If
          Next intA

          Also, the else part of this statement then permanently turns those pathways on, and they can no longer be deselected for Option1(0).

          Please advise!!! and thanks!

          DonnaDarko

          Comment

          • Taftheman
            New Member
            • Nov 2006
            • 93

            #6
            Originally posted by DonnaDarko
            Hello again!

            What was suggested so far, isn't working. It gets lost in the array somewhere, confusing i think the number of elements associated with the Option1(i) button, which goes from 0 to 2, and the Check1(i) array, which goes from 0 to 14.


            Here is what I now have, which doesn't work at all:

            Dim intA As Integer
            For intA = 1 To 14
            If receptor.Option 1(intA).Value = True Then
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text2(intA).E nabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text4(intA).E nabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text5(intA).E nabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text6(intA).E nabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text7(intA).E nabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text11(intA). Enabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text12(intA). Enabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text13(intA). Enabled = False
            Check1(intA).En abled = False
            Check1(intA).Va lue = 0
            frmexposurepath s.Text14(intA). Enabled = False
            Else
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text2(intA).E nabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text4(intA).E nabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text5(intA).E nabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text6(intA).E nabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text7(intA).E nabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text11(intA). Enabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text12(intA). Enabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text13(intA). Enabled = True
            Check1(intA).En abled = True
            Check1(intA).Va lue = 1
            frmexposurepath s.Text14(intA). Enabled = True
            End If
            Next intA

            Also, the else part of this statement then permanently turns those pathways on, and they can no longer be deselected for Option1(0).

            Please advise!!! and thanks!

            DonnaDarko
            Hi i am not too sure on what you actually want however if you want to enable and disable the control and all of its array then you can do it in a loop

            Dim intcount as integer

            If receptor.Option 1(1).Value = True Then
            Check1(1).Enabl ed = False
            Check1(1).Value = 0
            For intcount = 0 to frmexposurepath s.Text2.count - 1
            frmexposurepath s.Text2(intcoun t).Enabled = False
            Next intcount
            Else
            Check1(1).Enabl ed = True
            Check1(1).Value = 1
            For intcount = 0 to frmexposurepath s.Text2.count - 1
            frmexposurepath s.Text2(intcoun t).Enabled = True
            next intcount
            End if


            hope this helps

            Comment

            • DonnaDarko
              New Member
              • Mar 2007
              • 8

              #7
              Hi,

              Okay, next question; what you suggested has solved the problem of controlling the frame containing the textboxes, THANK YOU. But, I still don't have proper control of the option buttons. This is difficult to explain online i guess, but thank you for trying to understand me anyway!! Here goes:

              The Option1(i) button is an array that goes from 0 to 2. If Option1(1) is selected, then i want to enable and disable the checkboxes located in the same frame as the option button (as well as the textboxes, which are located on a different form, and which has been solved by the earlier reply). However, switching between e.g. Option1(0) and Option1(1) does not deactivate the associated Check1(i) buttons as shown above. I show a smaller selection below including the changes made for the textboxes.

              Dim intcount As Integer
              If receptor.Option 1(1).Value = True Then
              Check1(1).Enabl ed = False
              Check1(1).Value = 0
              For intcount = 0 To frmexposurepath s.Text2.Count - 1
              frmexposurepath s.Text2(intcoun t).Enabled = False
              Next intcount
              Check1(3).Enabl ed = False
              Check1(3).Value = 0
              For intcount = 0 To frmexposurepath s.Text4.Count - 1
              frmexposurepath s.Text4(intcoun t).Enabled = False
              Next intcount
              Else
              Check1(1).Enabl ed = True
              Check1(1).Value = 1
              For intcount = 0 To frmexposurepath s.Text2.Count - 1
              frmexposurepath s.Text2(intcoun t).Enabled = True
              Next intcount
              Check1(3).Enabl ed = True
              Check1(3).Value = 1
              For intcount = 0 To frmexposurepath s.Text4.Count - 1
              frmexposurepath s.Text4(intcoun t).Enabled = True
              Next intcount
              End If
              _______________ ____________

              I already tried creating a loop, using:

              Dim intA As Integer
              For intA = 0 To 2 'my Option1 button has 3 choices
              ........

              but this didn't work. After all, i need it to recognize and differentiate between the different options. So if Option1(0) is selected, then everything should be enabled, and if Option1(1) is selected, then the specified Checkboxes should be deactivated (along with their textboxes). But this isnt working yet. The other problem is, that, by specifying after the Else, that the Check1(i).Value = 1, i think this permanently turns the checkbox on; which i also dont want.

              BTW, do i have to include programming in the OKButton section as well as the Form_load section of the code on this form???

              Can you help me again?!! Thanks soooo much!

              Comment

              • Taftheman
                New Member
                • Nov 2006
                • 93

                #8
                Originally posted by DonnaDarko
                Hi,

                Okay, next question; what you suggested has solved the problem of controlling the frame containing the textboxes, THANK YOU. But, I still don't have proper control of the option buttons. This is difficult to explain online i guess, but thank you for trying to understand me anyway!! Here goes:

                The Option1(i) button is an array that goes from 0 to 2. If Option1(1) is selected, then i want to enable and disable the checkboxes located in the same frame as the option button (as well as the textboxes, which are located on a different form, and which has been solved by the earlier reply). However, switching between e.g. Option1(0) and Option1(1) does not deactivate the associated Check1(i) buttons as shown above. I show a smaller selection below including the changes made for the textboxes.

                Dim intcount As Integer
                If receptor.Option 1(1).Value = True Then
                Check1(1).Enabl ed = False
                Check1(1).Value = 0
                For intcount = 0 To frmexposurepath s.Text2.Count - 1
                frmexposurepath s.Text2(intcoun t).Enabled = False
                Next intcount
                Check1(3).Enabl ed = False
                Check1(3).Value = 0
                For intcount = 0 To frmexposurepath s.Text4.Count - 1
                frmexposurepath s.Text4(intcoun t).Enabled = False
                Next intcount
                Else
                Check1(1).Enabl ed = True
                Check1(1).Value = 1
                For intcount = 0 To frmexposurepath s.Text2.Count - 1
                frmexposurepath s.Text2(intcoun t).Enabled = True
                Next intcount
                Check1(3).Enabl ed = True
                Check1(3).Value = 1
                For intcount = 0 To frmexposurepath s.Text4.Count - 1
                frmexposurepath s.Text4(intcoun t).Enabled = True
                Next intcount
                End If
                _______________ ____________

                I already tried creating a loop, using:

                Dim intA As Integer
                For intA = 0 To 2 'my Option1 button has 3 choices
                ........

                but this didn't work. After all, i need it to recognize and differentiate between the different options. So if Option1(0) is selected, then everything should be enabled, and if Option1(1) is selected, then the specified Checkboxes should be deactivated (along with their textboxes). But this isnt working yet. The other problem is, that, by specifying after the Else, that the Check1(i).Value = 1, i think this permanently turns the checkbox on; which i also dont want.

                BTW, do i have to include programming in the OKButton section as well as the Form_load section of the code on this form???

                Can you help me again?!! Thanks soooo much!
                Hi obviously the first thing i noticed was that option(0) has no code to it so you can use a loop from 0 to 1 so it only uses thoes two controls or just fudge it and if the option buttons are an array double click into it and paste what you have done in the Click event. (Index) is the array count so where you have
                option(0) use option(index), if you chose check(i).value = 1 will apply a tick in the checkbox this can be got ridden of by check(i).value = 0

                Comment

                • DonnaDarko
                  New Member
                  • Mar 2007
                  • 8

                  #9
                  Hello!

                  Problem solved! Thank you so much for the help. Actually, the last problem was that the code was in the wrong place. So i added a Call function for the subroutine associated with the Option1(i) button and deleted the code completely from the Form_load section. You gave me the idea when you mentioned there was no code associated with the Option button. Such a silly mistake!

                  Thanks!!

                  Comment

                  Working...