how to join up a string and a integer to be a object name ?

Discussion in 'ASP .Net' started by THY, Nov 8, 2003.

  1. THY

    THY Guest

    Hi,

    Assuming that I have 5 textboxes, they are textbox1, textbox2, textbox3,
    textbox4, textbox5.
    and now I am on a for loop as below. but how can I make it join the word
    "textbox" and my i value together and be a textbox object ?

    it should be something like that, but I dont know the real coding.

    for i = 1 to 5
    ("textbox" & i).text = "hello"
    next


    anyone know it ?

    your help is real appreaciated. Thanks.
     
    THY, Nov 8, 2003
    #1
    1. Advertising

  2. THY

    Jos Guest

    THY wrote:
    > Hi,
    >
    > Assuming that I have 5 textboxes, they are textbox1, textbox2,
    > textbox3, textbox4, textbox5.
    > and now I am on a for loop as below. but how can I make it join the
    > word "textbox" and my i value together and be a textbox object ?
    >
    > it should be something like that, but I dont know the real coding.
    >
    > for i = 1 to 5
    > ("textbox" & i).text = "hello"
    > next


    CType(FindControl("textbox" & i),TextBox).Text="Hello"

    --

    Jos
     
    Jos, Nov 8, 2003
    #2
    1. Advertising

  3. THY

    THY Guest

    Thanks a lot !



    "Jos" <> wrote in message
    news:%...
    > THY wrote:
    > > Hi,
    > >
    > > Assuming that I have 5 textboxes, they are textbox1, textbox2,
    > > textbox3, textbox4, textbox5.
    > > and now I am on a for loop as below. but how can I make it join the
    > > word "textbox" and my i value together and be a textbox object ?
    > >
    > > it should be something like that, but I dont know the real coding.
    > >
    > > for i = 1 to 5
    > > ("textbox" & i).text = "hello"
    > > next

    >
    > CType(FindControl("textbox" & i),TextBox).Text="Hello"
    >
    > --
    >
    > Jos
    >
    >
     
    THY, Nov 8, 2003
    #3
  4. "THY" <> wrote in message
    news:...
    > Hi,
    >
    > Assuming that I have 5 textboxes, they are textbox1, textbox2, textbox3,
    > textbox4, textbox5.
    > and now I am on a for loop as below. but how can I make it join the word
    > "textbox" and my i value together and be a textbox object ?
    >
    > it should be something like that, but I dont know the real coding.
    >
    > for i = 1 to 5
    > ("textbox" & i).text = "hello"
    > next
    >


    Private textBoxArray As TextBox() = New TextBox() {textbox1, textbox2, ...
    textbox5}

    For i = 1 To 5
    textBoxArray(i).Text = "hello"
    Next

    --
    John
     
    John Saunders, Nov 8, 2003
    #4
  5. THY

    THY Guest

    This is a good way too, thanks John !

    "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    news:...
    > "THY" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Assuming that I have 5 textboxes, they are textbox1, textbox2, textbox3,
    > > textbox4, textbox5.
    > > and now I am on a for loop as below. but how can I make it join the word
    > > "textbox" and my i value together and be a textbox object ?
    > >
    > > it should be something like that, but I dont know the real coding.
    > >
    > > for i = 1 to 5
    > > ("textbox" & i).text = "hello"
    > > next
    > >

    >
    > Private textBoxArray As TextBox() = New TextBox() {textbox1, textbox2, ...
    > textbox5}
    >
    > For i = 1 To 5
    > textBoxArray(i).Text = "hello"
    > Next
    >
    > --
    > John
    >
    >
    >
     
    THY, Nov 8, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alan Silver
    Replies:
    0
    Views:
    897
    Alan Silver
    Jun 5, 2006
  2. googleboy
    Replies:
    1
    Views:
    936
    Benji York
    Oct 1, 2005
  3. Randy Kramer
    Replies:
    12
    Views:
    384
    Robert Klemme
    Oct 25, 2007
  4. iMath
    Replies:
    9
    Views:
    185
    Chris Angelico
    Jan 30, 2013
  5. Jean-Michel Pichavant
    Replies:
    0
    Views:
    139
    Jean-Michel Pichavant
    Jan 29, 2013
Loading...

Share This Page