Results 1 to 5 of 5

Thread: textbox collection(resolved by alextyx)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    textbox collection(resolved by alextyx)

    I want to create a textbox collection by the textboxes on my form, after I add two, i still get the collection's item count is 0.

    Here is my code:


    VB Code:
    1. Dim colText As TextBox.ControlCollection = New TextBox.ControlCollection(Me)
    2.         colText.Add(txtDBName)
    3.         colText.Add(txtFileName)
    Last edited by Palmtree; Apr 14th, 2004 at 09:15 AM.

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    i think the value for argument of ControlCollection method is Forms.Control and not a Form.

    VB Code:
    1. ControlCollection(Me.TextBox1)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    thanks for your reply.

    but I do not get it. your "Textbox1" can be either txtDBName or txtFileName or what?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Try this way:

    Dim Txt As TextBox
    Dim myCollection As New Collection
    myCollection.Add(Me.TextBox1)
    'Now Items.count=1
    Txt = CType(myCollection.Item(1), TextBox)
    'Now, for example, Txt.Text=TextBox1.text

    Good job!
    Live long and prosper (Mr. Spock)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    YES, fantastic job!

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