Output Textbox

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

    #1

    Output Textbox

    I'm having trouble getting input from a textbox in Visual Basic 6.0

    Private Sub cmdGetNumber_Cl ick()
    txtInput.Text = Str(Int(1000 * Rnd))
    End Sub

    The error message states: "Method or data member not found"

    The properties window of the textbox has "txtInput" next to "Name"

    In the coding window, when I type "txtInput." , a list of items
    appears. The list does not contain "Text".

    Why doesn't it work?
  • Rick Rothstein

    #2
    Re: Output Textbox

    > I'm having trouble getting input from a textbox in Visual Basic 6.0[color=blue]
    >
    > Private Sub cmdGetNumber_Cl ick()
    > txtInput.Text = Str(Int(1000 * Rnd))
    > End Sub
    >
    > The error message states: "Method or data member not found"
    >
    > The properties window of the textbox has "txtInput" next to "Name"
    >
    > In the coding window, when I type "txtInput." , a list of items
    > appears. The list does not contain "Text".
    >
    > Why doesn't it work?[/color]

    Are you absolutely sure you placed a TextBox and not some other control
    that looks like one (for example, a ListBox)? Check the text in the
    drop-down box at the top of the Properties box. Highlight what you think
    is a TextBox and see if the text in the drop-down says

    txtInput TextBox

    Out of curiosity, what are say the first 5 items listed when you type
    the "dot" after "txtInput"?

    Rick - MVP

    Comment

    • Karen

      #3
      Re: Output Textbox

      "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote:[color=blue]
      > Are you absolutely sure you placed a TextBox and not some other control
      > that looks like one (for example, a ListBox)?[/color]

      I checked. It's definitely a textbox.
      [color=blue]
      >
      > Out of curiosity, what are say the first 5 items listed when you type
      > the "dot" after "txtInput"?
      >[/color]

      That's the weird part. It only lists four items:
      Count
      Item
      LBound
      UBound

      If I type "txtInput.Item. ", I get a long list which contains "Text"

      Do I need to fix something?

      [color=blue][color=green]
      > > Private Sub cmdGetNumber_Cl ick()
      > > txtInput.Text = Str(Int(1000 * Rnd))
      > > End Sub
      > >
      > > The error message states: "Method or data member not found"
      > >
      > > The properties window of the textbox has "txtInput" next to "Name"
      > >
      > > In the coding window, when I type "txtInput." , a list of items
      > > appears. The list does not contain "Text".
      > >[/color][/color]

      Comment

      • Rick Rothstein

        #4
        Re: Output Textbox

        > > Are you absolutely sure you placed a TextBox and not some other
        control[color=blue][color=green]
        > > that looks like one (for example, a ListBox)?[/color]
        >
        > I checked. It's definitely a textbox.[color=green]
        > >
        > > Out of curiosity, what are say the first 5 items listed when you[/color][/color]
        type[color=blue][color=green]
        > > the "dot" after "txtInput"?
        > >[/color]
        > That's the weird part. It only lists four items:
        > Count
        > Item
        > LBound
        > UBound[/color]

        The problem you are having is because your TextBox is part of a Control
        Array of TextBoxes. Each member of the Control Array is an individual
        TextBox, but to address their properties, you have to specify which
        member of the Control Array you are addressing. You do that by including
        the Index number of the TextBox whose properties you want to change. For
        example, if the Index value of the TextBox you are trying to address is,
        say, 2, then you would do this

        txtInput(2).Tex t = "Whatever you are trying to assign"

        Now, if none of the above makes any sense to you<g>, then I'll assume
        you created the Control Array accidentally. If that is the case, then
        simply highlight the TextBox in question and delete (in the Properties
        box) whatever value is in its Index property. That will convert it back
        to a normal TextBox which you can address in the manner you are used to.
        If neither of the above covers your problem, post back here with more
        information.

        Rick - MVP

        Comment

        • Bob Butler

          #5
          Re: Output Textbox

          karen_t@mailina tor.com (Karen) wrote in message news:<e02f00cb. 0406031347.5727 3b64@posting.go ogle.com>...
          <cut>[color=blue]
          > That's the weird part. It only lists four items:
          > Count
          > Item
          > LBound
          > UBound[/color]

          <g>
          you set the Index property of the textbox and turned it into a control
          array; delete the value in the properties window for the Index and
          things should start working the way you expect again.

          Note that if you've created any event procedures they probably have an
          initial parameter reading "Index As Integer" and you'll get errors
          when you try to run that the event procedure doesn't match. Delete
          that first Index parameter from the event. For exampe, change:
          Private Sub Text1_Change(In dex As Integer)
          to:
          Private Sub Text1_Change()

          and
          Private Sub Text1_Validate( Index As Integer, Cancel As Boolean)
          to
          Private Sub Text1_Validate( Cancel As Boolean)

          Comment

          • Andy Crick

            #6
            Re: Output Textbox

            Not sure you got an answer -
            looks like you have a control array rather than a plain textbox
            the textbox has an index property set to something rather than blank.


            "Karen" <karen_t@mailin ator.com> wrote in message
            news:e02f00cb.0 406031347.57273 b64@posting.goo gle.com...[color=blue]
            > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote:[color=green]
            > > Are you absolutely sure you placed a TextBox and not some other control
            > > that looks like one (for example, a ListBox)?[/color]
            >
            > I checked. It's definitely a textbox.
            >[color=green]
            > >
            > > Out of curiosity, what are say the first 5 items listed when you type
            > > the "dot" after "txtInput"?
            > >[/color]
            >
            > That's the weird part. It only lists four items:
            > Count
            > Item
            > LBound
            > UBound
            >
            > If I type "txtInput.Item. ", I get a long list which contains "Text"
            >
            > Do I need to fix something?
            >
            >[color=green][color=darkred]
            > > > Private Sub cmdGetNumber_Cl ick()
            > > > txtInput.Text = Str(Int(1000 * Rnd))
            > > > End Sub
            > > >
            > > > The error message states: "Method or data member not found"
            > > >
            > > > The properties window of the textbox has "txtInput" next to "Name"
            > > >
            > > > In the coding window, when I type "txtInput." , a list of items
            > > > appears. The list does not contain "Text".
            > > >[/color][/color][/color]


            Comment

            • Karen

              #7
              Re: Output Textbox

              Bob Butler wrote:[color=blue]
              > delete the value in the properties window for the Index[/color]

              That fixed it.

              Thanks guys!

              Karen

              Comment

              Working...