Results 1 to 7 of 7

Thread: curious

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    medina, OH
    Posts
    125

    curious

    i am curious what exactly is a control array?
    "Sometimes the only way you can feel good about yourself is by making someone else look bad And I'm tired of making other people feel good about themselves"-Homer Simpson

  2. #2
    DaoK
    Guest
    Control array is like you put 1 textbox who will have the same name like text1 with a number after it : text1(0).text text1(1).text.

    It have many advantage, like you can do some loop :
    VB Code:
    1. For i = 0 to ubound(text1) ' Ubound = length of array
    2.    text1(i).text = "HI"
    3. Next i

    Array keep order in the form and I think it take less memory but I am not sure.

  3. #3
    As the name states, it is an array of controls. It is quite useful; for example if you need to get 10 strings from a user, you can add 10 TextBoxes on a form and do this:
    VB Code:
    1. Dim i As Long
    2. For i = 0 To txtMyArray.Count - 1
    3.     Msgbox "TextBox #" & i & " contained " & txtMyArray(i).Text
    4. Next i
    Also, VB has a limit of 255 controls on one form. But a control array counts as only one control.

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by DaoK
    VB Code:
    1. For i = 0 to ubound(text1) ' Ubound = length of array
    2.    text1(i).text = "HI"
    3. Next i
    I guess it should be:
    VB Code:
    1. For i = 0 to text1.ubound ' Ubound = length of array
    2.    text1(i).text = "HI"
    3. Next i
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    VB Code:
    1. Text1.Count
    Actually.

  6. #6
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Actually, it should be .Ubound and have an errorhandler code, in case some of the indexes don't exist. .Count would only return the number of controls there are.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  7. #7
    DaoK
    Guest
    Ubound is for variable sorry!!!

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