Detect Object Index

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

    Detect Object Index

    How can I detect if object with specific index exists?
    E.g. I load text box and give it random index number between 0 and 5.
    Now I have to set some text in textbox so I need to detect it but I
    don't know what index I gave it!

    Private Sub Form_Load()
    Dim x As Integer
    x = Rnd * 5
    Load Text1(x)
    End Sub

    And I need to find out that x!
    How can I do that?

    By WhiteRavenEye <aka ColdFusion>

  • River

    #2
    Re: Detect Object Index

    on your form click on your text box then look at your properties it will
    tell you the name of the object selected.
    "WhiteRaven Eye" <whiteraveneye@ hotmail.com> wrote in message
    news:be440p$2ht $1@brown.net4u. hr...[color=blue]
    > How can I detect if object with specific index exists?
    > E.g. I load text box and give it random index number between 0 and 5.
    > Now I have to set some text in textbox so I need to detect it but I
    > don't know what index I gave it!
    >
    > Private Sub Form_Load()
    > Dim x As Integer
    > x = Rnd * 5
    > Load Text1(x)
    > End Sub
    >
    > And I need to find out that x!
    > How can I do that?
    >
    > By WhiteRavenEye <aka ColdFusion>
    >[/color]


    Comment

    • Roger Barker

      #3
      Re: Detect Object Index

      In article <be440p$2ht$1@b rown.net4u.hr>, WhiteRavenEye
      <whiteraveneye@ hotmail.com> writes[color=blue]
      >How can I detect if object with specific index exists?
      >E.g. I load text box and give it random index number between 0 and 5.
      >Now I have to set some text in textbox so I need to detect it but I
      >don't know what index I gave it!
      >
      >Private Sub Form_Load()
      >Dim x As Integer
      >x = Rnd * 5
      >Load Text1(x)
      >End Sub
      >
      >And I need to find out that x!
      >How can I do that?[/color]

      Something like this?

      Dim ctlT As Control

      For Each ctlT In Controls
      If TypeOf ctlT Is TextBox And ctlT.Name = "Text1" Then _
      Debug.Print ctlT.Index
      Next ctlT


      --
      Roger Barker roger@peaksys.c o.uk
      Boston, UK

      Comment

      • WhiteRavenEye

        #4
        Re: Detect Object Index

        Roger Barker wrote:[color=blue]
        > In article <be440p$2ht$1@b rown.net4u.hr>, WhiteRavenEye
        > <whiteraveneye@ hotmail.com> writes
        >[color=green]
        >>How can I detect if object with specific index exists?
        >>E.g. I load text box and give it random index number between 0 and 5.
        >>Now I have to set some text in textbox so I need to detect it but I
        >>don't know what index I gave it!
        >>
        >>Private Sub Form_Load()
        >>Dim x As Integer
        >>x = Rnd * 5
        >>Load Text1(x)
        >>End Sub
        >>
        >>And I need to find out that x!
        >>How can I do that?[/color]
        >
        >
        > Something like this?
        >
        > Dim ctlT As Control
        >
        > For Each ctlT In Controls
        > If TypeOf ctlT Is TextBox And ctlT.Name = "Text1" Then _
        > Debug.Print ctlT.Index
        > Next ctlT[/color]

        Yes, yes, yes!!!!
        That's exactly what I needed!
        Thanks... You saved me a lot of headache...

        By WhiteRavenEye <aka SysCold>

        Comment

        • Samir Talwar

          #5
          Re: Detect Object Index

          That's what I would have thought as well. Obviously some people chose
          to ignore the simple stuff and go with the complicated - I suppose you
          can make your program look more nerdy like that.
          Samir Talwar

          david_wimbush@h otmail.com (David Wimbush) wrote in message news:<3ccf514f. 0307080037.565d 7c9f@posting.go ogle.com>...[color=blue]
          > Surely Don's suggestion of making a note of x in the first place is much better?
          >
          > WhiteRavenEye <whiteraveneye@ hotmail.com> wrote in message news:<be6mkn$np 7$1@brown.net4u .hr>...[color=green]
          > > Roger Barker wrote:[color=darkred]
          > > > In article <be440p$2ht$1@b rown.net4u.hr>, WhiteRavenEye
          > > > <whiteraveneye@ hotmail.com> writes
          > > >
          > > >>How can I detect if object with specific index exists?
          > > >>E.g. I load text box and give it random index number between 0 and 5.
          > > >>Now I have to set some text in textbox so I need to detect it but I
          > > >>don't know what index I gave it!
          > > >>
          > > >>Private Sub Form_Load()
          > > >>Dim x As Integer
          > > >>x = Rnd * 5
          > > >>Load Text1(x)
          > > >>End Sub
          > > >>
          > > >>And I need to find out that x!
          > > >>How can I do that?
          > > >
          > > >
          > > > Something like this?
          > > >
          > > > Dim ctlT As Control
          > > >
          > > > For Each ctlT In Controls
          > > > If TypeOf ctlT Is TextBox And ctlT.Name = "Text1" Then _
          > > > Debug.Print ctlT.Index
          > > > Next ctlT[/color]
          > >
          > > Yes, yes, yes!!!!
          > > That's exactly what I needed!
          > > Thanks... You saved me a lot of headache...
          > >
          > > By WhiteRavenEye <aka SysCold>[/color][/color]

          Comment

          Working...