• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

Numof of elements in an array

In visual basic 6, how do i tell how many elements are in an array?

Private Function GetData(TblKey As String)

Dim WkKey As Variant
WkKey = Split(TblKey, ",")

How can i tell how many elements or occurences are in WkKey?
0
tomhoran
Asked:
tomhoran
  • 2
  • 2
  • 2
1 Solution
 
tomhoranAuthor Commented:
Adjusted points from 5 to 10
0
 
GivenRandyCommented:
UBound(WkKey) - LBound(WkKey) + 1
0
 
pauljkCommented:
ubound(WkKey) + 1

This will give you the count of occurences.
+1 becuase it starts at 0.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
pauljkCommented:
Beware...  You will get an error if you do not have any elements in your array.
0
 
GivenRandyCommented:
Pauljk, my solution is more complete and before yours was submitted.  Why did you set yours as the proposed answer?  Well, hopefully tomhoran notices this.  
0
 
tomhoranAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now