Results 1 to 6 of 6

Thread: Textbox array?

  1. #1

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

    Question Textbox array?

    I've started using VB.net instead of VB6. I'm missing the possiblity of making textboxes as an array. In VB6 this is standard, but is it possible at all in VB.Net?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    There are no control arrays in .net like there was in VB6.

    What is it your trying to do?

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    to make a control array in .NET you create for example 3 textboxes named text1,text2,text3 respectively. Then in the text1 change event(Or any event) where it says Handles you append the extra textbox names and events.

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged

    I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.
    The way to figure out which one is to cast the sender object to a textbox, then refer to the senders name.
    VB Code:
    1. Dim myTextBox As TextBox
    2. myTextBox = CType(sender, TextBox)
    3.  
    4. If myTextBox.Name = TextBox1 Then
    5.    '  Do your processing for textbox 1.
    6. End If
    7.  
    8. If myTextBox.Name = TextBox2 Then
    9.    '  Do your processing for textbox 2.
    10. End If

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    I have a this sub:
    Code:
    Private Sub btnNulstil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNulstil.Click
            txtKar1.Text = ""
            txtKar2.Text = ""
            txtKar3.Text = ""
            txtKar4.Text = ""
            txtKar5.Text = ""
        End Sub
    Imagine that I had 100 text boxes, I would'nt like to write the lines txtKarX.text ="" up to 100. How can I make this in a smart way?

  6. #6
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    good question.. and i have no earthly idea why microsoft got rid of control arrays.

    But i would think you would loop thru them using some sort of Object collection thingy.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


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