Results 1 to 6 of 6

Thread: [RESOLVED] Find out how many labels are in a label array?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [RESOLVED] Find out how many labels are in a label array?

    Hi there folks!

    Would anyone know about Ubound, and if it could tell me how many labels are in a label array? It doesn't matter if it has text in the label caption or not.

    My label array is called lblWordLetter, so I tried...



    Dim nElements As Long
    nElements = UBound(lblWordLetter) - LBound(lblWordLetter) + 1

    MsgBox nElements

    The problem is I get an error saying "array", and it highlights the word UBound in the code above.

    Where did I go wrong? : )

    Thanks!

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,700

    Re: Find out how many labels are in a label array?

    It is:

    Code:
    nElements = lblWordLetter.Ubound

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,624

    Re: Find out how many labels are in a label array?

    use lblWordLetter.UBound

  4. #4
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Find out how many labels are in a label array?

    lblWordLetter.UBound will give you the highest Index in the Array; lblWordLetter.Count will give you the number of elements actually in the Array. This is significant because Control Arrays may not be continuous.

    e.g. you can have a lblWordLetter(0), lblWordLetter(2), lblWordLetter(3) without a lblWordLetter(1)

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,624

    Re: Find out how many labels are in a label array?

    good point!

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Find out how many labels are in a label array?

    Thank you! You have all been very helpful!

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