How to access TextBox Controls.Item 1.Caption?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bettyann

    How to access TextBox Controls.Item 1.Caption?

    I am using Visual Basic 6.0.

    I have a TextBox control whose "Caption" I wish to access. When I
    look at the TextBox's structure via the "watch" window, its structure
    appears to look like the following:

    myTextBox.Contr ols.Item 1.Caption

    How do I code the "Item 1" structure since it has a [space] between
    the "Item" and the "1"?

    The following (and numerous variations on this theme) causes an error:

    MsgBox "Empty Tag in " & myTextBox.Contr ols.[Item 1].Caption & "!"

    tia,
    - bettyann
  • Rick Rothstein

    #2
    Re: How to access TextBox Controls.Item 1.Caption?

    > I am using Visual Basic 6.0.[color=blue]
    >
    > I have a TextBox control whose "Caption" I wish to access. When I
    > look at the TextBox's structure via the "watch" window, its structure
    > appears to look like the following:
    >
    > myTextBox.Contr ols.Item 1.Caption
    >
    > How do I code the "Item 1" structure since it has a [space] between
    > the "Item" and the "1"?
    >
    > The following (and numerous variations on this theme) causes an error:
    >
    > MsgBox "Empty Tag in " & myTextBox.Contr ols.[Item 1].Caption & "!"[/color]

    It's an object with a property, just reference it directly...

    MsgBox "Empty Tag in " & myTextBox.Capti on & "!"

    Rick - MVP


    Comment

    • Norman Yuan

      #3
      Re: How to access TextBox Controls.Item 1.Caption?

      Are you sure you are doing things in VB6? TextBox in VB does not have
      "Caption" property.

      "bettyann" <bettyann@campb ell.com> wrote in message
      news:287ea6c.04 03251117.3c194b c6@posting.goog le.com...[color=blue]
      > I am using Visual Basic 6.0.
      >
      > I have a TextBox control whose "Caption" I wish to access. When I
      > look at the TextBox's structure via the "watch" window, its structure
      > appears to look like the following:
      >
      > myTextBox.Contr ols.Item 1.Caption
      >
      > How do I code the "Item 1" structure since it has a [space] between
      > the "Item" and the "1"?
      >
      > The following (and numerous variations on this theme) causes an error:
      >
      > MsgBox "Empty Tag in " & myTextBox.Contr ols.[Item 1].Caption & "!"
      >
      > tia,
      > - bettyann[/color]


      Comment

      • Rick Rothstein

        #4
        Re: How to access TextBox Controls.Item 1.Caption?

        You should have posted your message under mine... boy do I feel stupid... I
        fell right into that trap (I've gotta read the messages more carefully, I've
        gotta read the messages more carefully, I've gotta read...<g>).

        Rick - MVP


        "Norman Yuan" <normanyuan@Rem oveThis.shaw.ca > wrote in message
        news:JgI8c.2764 $QO2.885@pd7tw1 no...[color=blue]
        > Are you sure you are doing things in VB6? TextBox in VB does not have
        > "Caption" property.
        >
        > "bettyann" <bettyann@campb ell.com> wrote in message
        > news:287ea6c.04 03251117.3c194b c6@posting.goog le.com...[color=green]
        > > I am using Visual Basic 6.0.
        > >
        > > I have a TextBox control whose "Caption" I wish to access. When I
        > > look at the TextBox's structure via the "watch" window, its structure
        > > appears to look like the following:
        > >
        > > myTextBox.Contr ols.Item 1.Caption
        > >
        > > How do I code the "Item 1" structure since it has a [space] between
        > > the "Item" and the "1"?
        > >
        > > The following (and numerous variations on this theme) causes an error:
        > >
        > > MsgBox "Empty Tag in " & myTextBox.Contr ols.[Item 1].Caption & "!"
        > >
        > > tia,
        > > - bettyann[/color]
        >
        >[/color]


        Comment

        • Rick Rothstein

          #5
          Re: How to access TextBox Controls.Item 1.Caption?

          Ignore my message and read Norman's post instead.

          Rick - MVP


          "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
          news:MqmdncZZQ6 2KrP7dRVn-uQ@comcast.com. ..[color=blue][color=green]
          > > I am using Visual Basic 6.0.
          > >
          > > I have a TextBox control whose "Caption" I wish to access. When I
          > > look at the TextBox's structure via the "watch" window, its structure
          > > appears to look like the following:
          > >
          > > myTextBox.Contr ols.Item 1.Caption
          > >
          > > How do I code the "Item 1" structure since it has a [space] between
          > > the "Item" and the "1"?
          > >
          > > The following (and numerous variations on this theme) causes an error:
          > >
          > > MsgBox "Empty Tag in " & myTextBox.Contr ols.[Item 1].Caption & "!"[/color]
          >
          > It's an object with a property, just reference it directly...
          >
          > MsgBox "Empty Tag in " & myTextBox.Capti on & "!"
          >
          > Rick - MVP
          >
          >[/color]


          Comment

          • bettyann

            #6
            Re: How to access TextBox Controls.Item 1.Caption?

            > Are you sure you are doing things in VB6? TextBox in VB does not have[color=blue]
            > "Caption" property.[/color]

            I am accessing VB6 via MSAccess. The TextBox is one which was created
            in MSAccess's "Design" Mode. I apologize as I did not realize that
            that made a difference.

            Is there a way to access myTextBox.Contr ols.[Item 1].Caption?

            Thanks,
            - BettyAnn

            Comment

            • Norman Yuan

              #7
              Re: How to access TextBox Controls.Item 1.Caption?

              there is two way to do it:

              a. myTextBox.Contr ols(0).Caption= "XXXX" ' or
              mYTextBox.Contr ols.Item(0).Cap tion="XXXX"
              b. myLabel.Caption ="XXXX" 'If you name the label as "myLabel"

              Do not confuse VB6 and Access VBA6. Your question could be answered quickly
              if you post to Access NG, such as "miscrosoft.pub lic.access".

              HTH

              "bettyann" <bettyann@campb ell.com> wrote in message
              news:287ea6c.04 03260837.71ca47 d5@posting.goog le.com...[color=blue][color=green]
              > > Are you sure you are doing things in VB6? TextBox in VB does not have
              > > "Caption" property.[/color]
              >
              > I am accessing VB6 via MSAccess. The TextBox is one which was created
              > in MSAccess's "Design" Mode. I apologize as I did not realize that
              > that made a difference.
              >
              > Is there a way to access myTextBox.Contr ols.[Item 1].Caption?
              >
              > Thanks,
              > - BettyAnn[/color]


              Comment

              • bettyann

                #8
                Re: How to access TextBox Controls.Item 1.Caption?

                > a. myTextBox.Contr ols(0).Caption= "XXXX" ' or[color=blue]
                > mYTextBox.Contr ols.Item(0).Cap tion="XXXX"
                > b. myLabel.Caption ="XXXX" 'If you name the label as "myLabel"[/color]

                thank you -- these examples did the trick. i did not think to use
                index (0) (altho i should have) because the watch-window listed array
                elements with an offset of 1.
                [color=blue]
                > Do not confuse VB6 and Access VBA6. Your question could be answered quickly
                > if you post to Access NG, such as "miscrosoft.pub lic.access".[/color]

                i didn't know VBA existed -- i thought VB was VB was VB. mistake.

                thanks again,
                - bettyann

                Comment

                Working...