Results 1 to 4 of 4

Thread: For ... Next and setting labels and texts

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question For ... Next and setting labels and texts

    I have a number of text fields named kappe1, kappe2 .... kappe10. In JavaScript I can use the code below for setting the values of all of the text fields:
    Code:
    for (i=1;i<11;i++){
    document.forside.elements('kappedim'+i).value = "90";
    }
    But what about ASP.Net? If I have the same 10 text fields, how can I make a sub or a function that do the same? Something like the code below:
    Code:
    Dim i As Integer
            For i = 1 To 10
                label & i & .text = 90 
            Next
    How can I make it work? How can the code "label1.text=90" be created using for ... next?

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    if you have something to add them to this would work

    Code:
    dim i as integer
    dim t as textbox=new textbox
        for i=0 to 10
            t.id=text & i
            t.value="90"
            page.controls.add(t)
       next
    "Find all you need in your mind if you take the time" -DT

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    This creates an error in the line t.id= text & i. And the next line must be t.text=90.

  4. #4
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    Just need to quote the word text:

    Code:
    dim i as integer
    dim t as textbox=new textbox
        for i=0 to 10
            t.id="text" & i
            t.text="90"
            page.controls.add(t)
       next
    "Find all you need in your mind if you take the time" -DT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width