Solved

Numof of elements in an array

Posted on 2000-05-17
6
343 Views
Last Modified: 2011-09-20
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
Comment
Question by:tomhoran
  • 2
  • 2
  • 2
6 Comments
 

Author Comment

by:tomhoran
ID: 2819715
Adjusted points from 5 to 10
0
 
LVL 9

Accepted Solution

by:
GivenRandy earned 10 total points
ID: 2819718
UBound(WkKey) - LBound(WkKey) + 1
0
 
LVL 1

Expert Comment

by:pauljk
ID: 2819721
ubound(WkKey) + 1

This will give you the count of occurences.
+1 becuase it starts at 0.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Expert Comment

by:pauljk
ID: 2819725
Beware...  You will get an error if you do not have any elements in your array.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2819736
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
 

Author Comment

by:tomhoran
ID: 2819744
Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now