Results 1 to 7 of 7

Thread: How can I create an array of TextBoxes or Labels?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Location
    Israel
    Posts
    25

    How can I create an array of TextBoxes or Labels?

    Please, give me a code... or link.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    well do you want an array of controls? or a control array??

    what are you trying to do exactly?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Location
    Israel
    Posts
    25
    I need an array of controls...

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    ok well lets say you have 2 text boxes on your form and you want to load them into an array

    VB Code:
    1. Dim txtBoxArray(1) as TextBox
    2. txtBoxArray(0) = Text1
    3. txtBoxArray(1) = Text2

    where Text1 and Text2 are the text boxes on your form..

    if you wanted labels and textboxes in the same array you could do something like

    VB Code:
    1. Dim MyControls(2) as Control
    2. MyControls(0) = Text1
    3. MyControls(1) = Text2
    4. MyControls(2) = Label1
    where Text1 and Text2 and Label1 are the controls on your form..

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Location
    Israel
    Posts
    25
    Thank you.
    But If I need 64 (chess) TextBoxes???

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    you would be better off with a control array for this than an array of controls... just make 64 boxes and name them all the same thing.. then they will all have an index property which is how you reference the individual boxes..

    but why would you be using textboxes for a chess game?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Location
    Israel
    Posts
    25
    OK, thanks.
    The chess I've said for example...

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